2013-03-29 21:45:00

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH] hfs: add error checking for hfs_find_init()

hfs_find_init() may fail with ENOMEM, but there are places,
where the returned value is not checked. The consequences can be
very unpleasant, e.g. kfree uninitialized pointer and
inappropriate mutex unlocking.

The patch adds checks for errors in hfs_find_init().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
fs/hfs/catalog.c | 12 +++++++++---
fs/hfs/dir.c | 8 ++++++--
fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
fs/hfs/hfs_fs.h | 2 +-
fs/hfs/inode.c | 11 +++++++++--
fs/hfs/super.c | 4 +++-
6 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 424b033..9569b39 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
return -ENOSPC;

sb = dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (err)
+ return err;

hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
@@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)

dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
sb = dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (res)
+ return res;

hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
res = hfs_brec_find(&fd);
@@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
dst_dir->i_ino, dst_name->name);
sb = src_dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
+ if (err)
+ return err;
dst_fd = src_fd;

/* find the old dir entry and read the data */
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 5f7f1ab..e1c8048 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
struct inode *inode = NULL;
int res;

- hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ if (res)
+ return ERR_PTR(res);
hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
res = hfs_brec_read(&fd, &rec, sizeof(rec));
if (res) {
@@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (filp->f_pos >= inode->i_size)
return 0;

- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (err)
+ return err;
hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
err = hfs_brec_find(&fd);
if (err)
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index a67955a..813447b 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
}

-static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
+static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
{
int res;

@@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
res = hfs_brec_find(fd);
if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
if (res != -ENOENT)
- return;
+ return res;
hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
} else {
if (res)
- return;
+ return res;
hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
}
+ return 0;
}

-void hfs_ext_write_extent(struct inode *inode)
+int hfs_ext_write_extent(struct inode *inode)
{
struct hfs_find_data fd;
+ int res = 0;

if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
- hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
- __hfs_ext_write_extent(inode, &fd);
+ res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+ if (res)
+ return res;
+ res = __hfs_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
+ return res;
}

static inline int __hfs_ext_read_extent(struct hfs_find_data *fd, struct hfs_extent *extent,
@@ -161,8 +166,11 @@ static inline int __hfs_ext_cache_extent(struct hfs_find_data *fd, struct inode
{
int res;

- if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY)
- __hfs_ext_write_extent(inode, fd);
+ if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
+ res = __hfs_ext_write_extent(inode, fd);
+ if (res)
+ return res;
+ }

res = __hfs_ext_read_extent(fd, HFS_I(inode)->cached_extents, inode->i_ino,
block, HFS_IS_RSRC(inode) ? HFS_FK_RSRC : HFS_FK_DATA);
@@ -185,9 +193,11 @@ static int hfs_ext_read_extent(struct inode *inode, u16 block)
block < HFS_I(inode)->cached_start + HFS_I(inode)->cached_blocks)
return 0;

- hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
- res = __hfs_ext_cache_extent(&fd, inode, block);
- hfs_find_exit(&fd);
+ res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+ if (!res) {
+ res = __hfs_ext_cache_extent(&fd, inode, block);
+ hfs_find_exit(&fd);
+ }
return res;
}

@@ -298,7 +308,9 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
if (total_blocks == blocks)
return 0;

- hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ if (res)
+ return res;
do {
res = __hfs_ext_read_extent(&fd, extent, cnid, total_blocks, type);
if (res)
@@ -438,7 +450,9 @@ out:

insert_extent:
dprint(DBG_EXTENT, "insert new extent\n");
- hfs_ext_write_extent(inode);
+ res = hfs_ext_write_extent(inode);
+ if (res)
+ goto out;

memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
HFS_I(inode)->cached_extents[0].block = cpu_to_be16(start);
@@ -466,7 +480,6 @@ void hfs_file_truncate(struct inode *inode)
struct address_space *mapping = inode->i_mapping;
void *fsdata;
struct page *page;
- int res;

/* XXX: Can use generic_cont_expand? */
size = inode->i_size - 1;
@@ -488,7 +501,12 @@ void hfs_file_truncate(struct inode *inode)
goto out;

mutex_lock(&HFS_I(inode)->extents_lock);
- hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ if (res) {
+ mutex_unlock(&HFS_I(inode)->extents_lock);
+ /* XXX: We lack error handling of hfs_file_truncate() */
+ return;
+ }
while (1) {
if (alloc_cnt == HFS_I(inode)->first_blocks) {
hfs_free_extents(sb, HFS_I(inode)->first_extents,
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 693df9f..67817af 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -174,7 +174,7 @@ extern const struct inode_operations hfs_dir_inode_operations;
/* extent.c */
extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
-extern void hfs_ext_write_extent(struct inode *);
+extern int hfs_ext_write_extent(struct inode *);
extern int hfs_extend_file(struct inode *);
extern void hfs_file_truncate(struct inode *);

diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 3031dfd..8ff4b5a 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -416,9 +416,12 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
struct inode *main_inode = inode;
struct hfs_find_data fd;
hfs_cat_rec rec;
+ int res;

dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
- hfs_ext_write_extent(inode);
+ res = hfs_ext_write_extent(inode);
+ if (res)
+ return res;

if (inode->i_ino < HFS_FIRSTUSER_CNID) {
switch (inode->i_ino) {
@@ -515,7 +518,11 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
if (!inode)
return ERR_PTR(-ENOMEM);

- hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ if (res) {
+ iput(inode);
+ return ERR_PTR(res);
+ }
fd.search_key->cat = HFS_I(dir)->cat_key;
res = hfs_brec_read(&fd, &rec, sizeof(rec));
if (!res) {
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index bbaaa8a..719760b 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -418,7 +418,9 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
}

/* try to get the root inode */
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (res)
+ goto bail_no_root;
res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
if (!res) {
if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
--
1.7.9.5


2013-03-30 10:28:09

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()

Hi Alexey,

On Mar 30, 2013, at 12:44 AM, Alexey Khoroshilov wrote:

> hfs_find_init() may fail with ENOMEM, but there are places,
> where the returned value is not checked. The consequences can be
> very unpleasant, e.g. kfree uninitialized pointer and
> inappropriate mutex unlocking.
>
> The patch adds checks for errors in hfs_find_init().
>

Thank you for your efforts. I have several remarks. Please, see below.

> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---
> fs/hfs/catalog.c | 12 +++++++++---
> fs/hfs/dir.c | 8 ++++++--
> fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
> fs/hfs/hfs_fs.h | 2 +-
> fs/hfs/inode.c | 11 +++++++++--
> fs/hfs/super.c | 4 +++-
> 6 files changed, 61 insertions(+), 24 deletions(-)
>
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index 424b033..9569b39 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
> return -ENOSPC;
>
> sb = dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (err)
> + return err;
>
> hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
> entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
> @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
>
> dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
> sb = dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (res)
> + return res;
>
> hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
> res = hfs_brec_find(&fd);
> @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
> dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
> dst_dir->i_ino, dst_name->name);
> sb = src_dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> + if (err)
> + return err;
> dst_fd = src_fd;
>
> /* find the old dir entry and read the data */
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 5f7f1ab..e1c8048 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
> struct inode *inode = NULL;
> int res;
>
> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + if (res)
> + return ERR_PTR(res);
> hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
> res = hfs_brec_read(&fd, &rec, sizeof(rec));
> if (res) {
> @@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
> if (filp->f_pos >= inode->i_size)
> return 0;
>
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (err)
> + return err;
> hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
> err = hfs_brec_find(&fd);
> if (err)
> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
> index a67955a..813447b 100644
> --- a/fs/hfs/extent.c
> +++ b/fs/hfs/extent.c
> @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
> return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
> }
>
> -static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
> +static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
> {
> int res;
>
> @@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
> res = hfs_brec_find(fd);
> if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
> if (res != -ENOENT)
> - return;
> + return res;
> hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
> HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
> } else {
> if (res)
> - return;
> + return res;
> hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
> HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
> }
> + return 0;
> }
>

As I see, this fix makes sense and for hfsplus also. Please, make it and for hfsplus.

> -void hfs_ext_write_extent(struct inode *inode)
> +int hfs_ext_write_extent(struct inode *inode)
> {
> struct hfs_find_data fd;
> + int res = 0;
>
> if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
> - hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> - __hfs_ext_write_extent(inode, &fd);
> + res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> + if (res)
> + return res;
> + res = __hfs_ext_write_extent(inode, &fd);
> hfs_find_exit(&fd);
> }
> + return res;
> }
>
> static inline int __hfs_ext_read_extent(struct hfs_find_data *fd, struct hfs_extent *extent,
> @@ -161,8 +166,11 @@ static inline int __hfs_ext_cache_extent(struct hfs_find_data *fd, struct inode
> {
> int res;
>
> - if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY)
> - __hfs_ext_write_extent(inode, fd);
> + if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
> + res = __hfs_ext_write_extent(inode, fd);
> + if (res)
> + return res;
> + }
>

Ditto for hfsplus.

Thanks,
Vyacheslav Dubeyko.

> res = __hfs_ext_read_extent(fd, HFS_I(inode)->cached_extents, inode->i_ino,
> block, HFS_IS_RSRC(inode) ? HFS_FK_RSRC : HFS_FK_DATA);
> @@ -185,9 +193,11 @@ static int hfs_ext_read_extent(struct inode *inode, u16 block)
> block < HFS_I(inode)->cached_start + HFS_I(inode)->cached_blocks)
> return 0;
>
> - hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> - res = __hfs_ext_cache_extent(&fd, inode, block);
> - hfs_find_exit(&fd);
> + res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> + if (!res) {
> + res = __hfs_ext_cache_extent(&fd, inode, block);
> + hfs_find_exit(&fd);
> + }
> return res;
> }
>
> @@ -298,7 +308,9 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
> if (total_blocks == blocks)
> return 0;
>
> - hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + if (res)
> + return res;
> do {
> res = __hfs_ext_read_extent(&fd, extent, cnid, total_blocks, type);
> if (res)
> @@ -438,7 +450,9 @@ out:
>
> insert_extent:
> dprint(DBG_EXTENT, "insert new extent\n");
> - hfs_ext_write_extent(inode);
> + res = hfs_ext_write_extent(inode);
> + if (res)
> + goto out;
>
> memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
> HFS_I(inode)->cached_extents[0].block = cpu_to_be16(start);
> @@ -466,7 +480,6 @@ void hfs_file_truncate(struct inode *inode)
> struct address_space *mapping = inode->i_mapping;
> void *fsdata;
> struct page *page;
> - int res;
>
> /* XXX: Can use generic_cont_expand? */
> size = inode->i_size - 1;
> @@ -488,7 +501,12 @@ void hfs_file_truncate(struct inode *inode)
> goto out;
>
> mutex_lock(&HFS_I(inode)->extents_lock);
> - hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + if (res) {
> + mutex_unlock(&HFS_I(inode)->extents_lock);
> + /* XXX: We lack error handling of hfs_file_truncate() */
> + return;
> + }
> while (1) {
> if (alloc_cnt == HFS_I(inode)->first_blocks) {
> hfs_free_extents(sb, HFS_I(inode)->first_extents,
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index 693df9f..67817af 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -174,7 +174,7 @@ extern const struct inode_operations hfs_dir_inode_operations;
> /* extent.c */
> extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
> extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
> -extern void hfs_ext_write_extent(struct inode *);
> +extern int hfs_ext_write_extent(struct inode *);
> extern int hfs_extend_file(struct inode *);
> extern void hfs_file_truncate(struct inode *);
>
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 3031dfd..8ff4b5a 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -416,9 +416,12 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
> struct inode *main_inode = inode;
> struct hfs_find_data fd;
> hfs_cat_rec rec;
> + int res;
>
> dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
> - hfs_ext_write_extent(inode);
> + res = hfs_ext_write_extent(inode);
> + if (res)
> + return res;
>
> if (inode->i_ino < HFS_FIRSTUSER_CNID) {
> switch (inode->i_ino) {
> @@ -515,7 +518,11 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
> if (!inode)
> return ERR_PTR(-ENOMEM);
>
> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + if (res) {
> + iput(inode);
> + return ERR_PTR(res);
> + }
> fd.search_key->cat = HFS_I(dir)->cat_key;
> res = hfs_brec_read(&fd, &rec, sizeof(rec));
> if (!res) {
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index bbaaa8a..719760b 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -418,7 +418,9 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
> }
>
> /* try to get the root inode */
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (res)
> + goto bail_no_root;
> res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
> if (!res) {
> if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2013-03-30 14:01:08

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()

--- On Sat, 30/3/13, Vyacheslav Dubeyko <[email protected]> wrote:

> From: Vyacheslav Dubeyko <[email protected]>
> Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()
> To: "Alexey Khoroshilov" <[email protected]>
> Cc: "Al Viro" <[email protected]>, "Artem Bityutskiy" <[email protected]>, "Christoph Hellwig" <[email protected]>, [email protected], [email protected], [email protected], "Hin-Tak Leung" <[email protected]>
> Date: Saturday, 30 March, 2013, 11:35
> Hi Alexey,
>
> On Mar 30, 2013, at 12:44 AM, Alexey Khoroshilov wrote:
>
> > hfs_find_init() may fail with ENOMEM, but there are
> places,
> > where the returned value is not checked. The
> consequences can be
> > very unpleasant, e.g. kfree uninitialized pointer and
> > inappropriate mutex unlocking.
> >
> > The patch adds checks for errors in hfs_find_init().
> >
>
> Thank you for your efforts. I have several remarks. Please,
> see below.

Argh, interesting. I wonder if that is related to how I can get the hfsplus driver all confused just running 'du' on one large directory in one of my disks repeatedly. I'll be interested to trying the hfsplus version out. Perhaps I would suggest/add a few dprint/printk's so that there is a sign in dmesg when the error condition is triggered.

Hin-Tak

> > Found by Linux Driver Verification project
> (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <[email protected]>
> > ---
> > fs/hfs/catalog.c |???12 +++++++++---
> > fs/hfs/dir.c? ???|? ? 8
> ++++++--
> > fs/hfs/extent.c? |???48
> +++++++++++++++++++++++++++++++++---------------
> > fs/hfs/hfs_fs.h? |? ? 2 +-
> > fs/hfs/inode.c???|???11
> +++++++++--
> > fs/hfs/super.c???|? ? 4 +++-
> > 6 files changed, 61 insertions(+), 24 deletions(-)
> >
> > diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> > index 424b033..9569b39 100644
> > --- a/fs/hfs/catalog.c
> > +++ b/fs/hfs/catalog.c
> > @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct
> inode *dir, struct qstr *str, struct inode *
> > ??? ??? return -ENOSPC;
> >
> > ??? sb = dir->i_sb;
> > -???
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? err =
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? if (err)
> > +??? ??? return err;
> >
> > ??? hfs_cat_build_key(sb, fd.search_key,
> cnid, NULL);
> > ??? entry_size =
> hfs_cat_build_thread(sb, &entry,
> S_ISDIR(inode->i_mode) ?
> > @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct
> inode *dir, struct qstr *str)
> >
> > ??? dprint(DBG_CAT_MOD, "delete_cat:
> %s,%u\n", str ? str->name : NULL, cnid);
> > ??? sb = dir->i_sb;
> > -???
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? if (res)
> > +??? ??? return res;
> >
> > ??? hfs_cat_build_key(sb, fd.search_key,
> dir->i_ino, str);
> > ??? res = hfs_brec_find(&fd);
> > @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct
> inode *src_dir, struct qstr *src_name,
> > ??? dprint(DBG_CAT_MOD, "rename_cat: %u
> - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino,
> src_name->name,
> > ??? ???
> dst_dir->i_ino, dst_name->name);
> > ??? sb = src_dir->i_sb;
> > -???
> hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> > +??? err =
> hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> > +??? if (err)
> > +??? ??? return err;
> > ??? dst_fd = src_fd;
> >
> > ??? /* find the old dir entry and read
> the data */
> > diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> > index 5f7f1ab..e1c8048 100644
> > --- a/fs/hfs/dir.c
> > +++ b/fs/hfs/dir.c
> > @@ -25,7 +25,9 @@ static struct dentry
> *hfs_lookup(struct inode *dir, struct dentry *dentry,
> > ??? struct inode *inode = NULL;
> > ??? int res;
> >
> > -???
> hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> > +??? if (res)
> > +??? ??? return
> ERR_PTR(res);
> > ??? hfs_cat_build_key(dir->i_sb,
> fd.search_key, dir->i_ino, &dentry->d_name);
> > ??? res = hfs_brec_read(&fd,
> &rec, sizeof(rec));
> > ??? if (res) {
> > @@ -63,7 +65,9 @@ static int hfs_readdir(struct file
> *filp, void *dirent, filldir_t filldir)
> > ??? if (filp->f_pos >=
> inode->i_size)
> > ??? ??? return 0;
> >
> > -???
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? err =
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? if (err)
> > +??? ??? return err;
> > ??? hfs_cat_build_key(sb, fd.search_key,
> inode->i_ino, NULL);
> > ??? err = hfs_brec_find(&fd);
> > ??? if (err)
> > diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
> > index a67955a..813447b 100644
> > --- a/fs/hfs/extent.c
> > +++ b/fs/hfs/extent.c
> > @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct
> hfs_extent *ext)
> > ??? return be16_to_cpu(ext->block) +
> be16_to_cpu(ext->count);
> > }
> >
> > -static void __hfs_ext_write_extent(struct inode
> *inode, struct hfs_find_data *fd)
> > +static int __hfs_ext_write_extent(struct inode *inode,
> struct hfs_find_data *fd)
> > {
> > ??? int res;
> >
> > @@ -116,26 +116,31 @@ static void
> __hfs_ext_write_extent(struct inode *inode, struct
> hfs_find_data *fd
> > ??? res = hfs_brec_find(fd);
> > ??? if (HFS_I(inode)->flags &
> HFS_FLG_EXT_NEW) {
> > ??? ??? if (res !=
> -ENOENT)
> > -??? ???
> ??? return;
> > +??? ???
> ??? return res;
> > ??? ???
> hfs_brec_insert(fd, HFS_I(inode)->cached_extents,
> sizeof(hfs_extent_rec));
> > ??? ???
> HFS_I(inode)->flags &=
> ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
> > ??? } else {
> > ??? ??? if (res)
> > -??? ???
> ??? return;
> > +??? ???
> ??? return res;
> > ??? ???
> hfs_bnode_write(fd->bnode,
> HFS_I(inode)->cached_extents, fd->entryoffset,
> fd->entrylength);
> > ??? ???
> HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
> > ??? }
> > +??? return 0;
> > }
> >
>
> As I see, this fix makes sense and for hfsplus also. Please,
> make it and for hfsplus.
>
> > -void hfs_ext_write_extent(struct inode *inode)
> > +int hfs_ext_write_extent(struct inode *inode)
> > {
> > ??? struct hfs_find_data fd;
> > +??? int res = 0;
> >
> > ??? if (HFS_I(inode)->flags &
> HFS_FLG_EXT_DIRTY) {
> > -??? ???
> hfs_find_init(HFS_SB(inode->i_sb)->ext_tree,
> &fd);
> > -??? ???
> __hfs_ext_write_extent(inode, &fd);
> > +??? ??? res =
> hfs_find_init(HFS_SB(inode->i_sb)->ext_tree,
> &fd);
> > +??? ??? if (res)
> > +??? ???
> ??? return res;
> > +??? ??? res =
> __hfs_ext_write_extent(inode, &fd);
> > ??? ???
> hfs_find_exit(&fd);
> > ??? }
> > +??? return res;
> > }
> >
> > static inline int __hfs_ext_read_extent(struct
> hfs_find_data *fd, struct hfs_extent *extent,
> > @@ -161,8 +166,11 @@ static inline int
> __hfs_ext_cache_extent(struct hfs_find_data *fd, struct
> inode
> > {
> > ??? int res;
> >
> > -??? if (HFS_I(inode)->flags &
> HFS_FLG_EXT_DIRTY)
> > -??? ???
> __hfs_ext_write_extent(inode, fd);
> > +??? if (HFS_I(inode)->flags &
> HFS_FLG_EXT_DIRTY) {
> > +??? ??? res =
> __hfs_ext_write_extent(inode, fd);
> > +??? ??? if (res)
> > +??? ???
> ??? return res;
> > +??? }
> >
>
> Ditto for hfsplus.
>
> Thanks,
> Vyacheslav Dubeyko.
>
> > ??? res = __hfs_ext_read_extent(fd,
> HFS_I(inode)->cached_extents, inode->i_ino,
> > ??? ???
> ??? ??? ? ? block,
> HFS_IS_RSRC(inode) ? HFS_FK_RSRC : HFS_FK_DATA);
> > @@ -185,9 +193,11 @@ static int
> hfs_ext_read_extent(struct inode *inode, u16 block)
> > ??? ? ? block <
> HFS_I(inode)->cached_start +
> HFS_I(inode)->cached_blocks)
> > ??? ??? return 0;
> >
> > -???
> hfs_find_init(HFS_SB(inode->i_sb)->ext_tree,
> &fd);
> > -??? res =
> __hfs_ext_cache_extent(&fd, inode, block);
> > -??? hfs_find_exit(&fd);
> > +??? res =
> hfs_find_init(HFS_SB(inode->i_sb)->ext_tree,
> &fd);
> > +??? if (!res) {
> > +??? ??? res =
> __hfs_ext_cache_extent(&fd, inode, block);
> > +??? ???
> hfs_find_exit(&fd);
> > +??? }
> > ??? return res;
> > }
> >
> > @@ -298,7 +308,9 @@ int hfs_free_fork(struct
> super_block *sb, struct hfs_cat_file *file, int type)
> > ??? if (total_blocks == blocks)
> > ??? ??? return 0;
> >
> > -???
> hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> > +??? if (res)
> > +??? ??? return res;
> > ??? do {
> > ??? ??? res =
> __hfs_ext_read_extent(&fd, extent, cnid, total_blocks,
> type);
> > ??? ??? if (res)
> > @@ -438,7 +450,9 @@ out:
> >
> > insert_extent:
> > ??? dprint(DBG_EXTENT, "insert new
> extent\n");
> > -??? hfs_ext_write_extent(inode);
> > +??? res = hfs_ext_write_extent(inode);
> > +??? if (res)
> > +??? ??? goto out;
> >
> > ???
> memset(HFS_I(inode)->cached_extents, 0,
> sizeof(hfs_extent_rec));
> > ???
> HFS_I(inode)->cached_extents[0].block =
> cpu_to_be16(start);
> > @@ -466,7 +480,6 @@ void hfs_file_truncate(struct inode
> *inode)
> > ??? ??? struct
> address_space *mapping = inode->i_mapping;
> > ??? ??? void *fsdata;
> > ??? ??? struct page
> *page;
> > -??? ??? int res;
> >
> > ??? ??? /* XXX: Can use
> generic_cont_expand? */
> > ??? ??? size =
> inode->i_size - 1;
> > @@ -488,7 +501,12 @@ void hfs_file_truncate(struct
> inode *inode)
> > ??? ??? goto out;
> >
> > ???
> mutex_lock(&HFS_I(inode)->extents_lock);
> > -???
> hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> > +??? if (res) {
> > +??? ???
> mutex_unlock(&HFS_I(inode)->extents_lock);
> > +??? ??? /* XXX: We lack
> error handling of hfs_file_truncate() */
> > +??? ??? return;
> > +??? }
> > ??? while (1) {
> > ??? ??? if (alloc_cnt ==
> HFS_I(inode)->first_blocks) {
> > ??? ???
> ??? hfs_free_extents(sb,
> HFS_I(inode)->first_extents,
> > diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> > index 693df9f..67817af 100644
> > --- a/fs/hfs/hfs_fs.h
> > +++ b/fs/hfs/hfs_fs.h
> > @@ -174,7 +174,7 @@ extern const struct
> inode_operations hfs_dir_inode_operations;
> > /* extent.c */
> > extern int hfs_ext_keycmp(const btree_key *, const
> btree_key *);
> > extern int hfs_free_fork(struct super_block *, struct
> hfs_cat_file *, int);
> > -extern void hfs_ext_write_extent(struct inode *);
> > +extern int hfs_ext_write_extent(struct inode *);
> > extern int hfs_extend_file(struct inode *);
> > extern void hfs_file_truncate(struct inode *);
> >
> > diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> > index 3031dfd..8ff4b5a 100644
> > --- a/fs/hfs/inode.c
> > +++ b/fs/hfs/inode.c
> > @@ -416,9 +416,12 @@ int hfs_write_inode(struct inode
> *inode, struct writeback_control *wbc)
> > ??? struct inode *main_inode = inode;
> > ??? struct hfs_find_data fd;
> > ??? hfs_cat_rec rec;
> > +??? int res;
> >
> > ??? dprint(DBG_INODE, "hfs_write_inode:
> %lu\n", inode->i_ino);
> > -??? hfs_ext_write_extent(inode);
> > +??? res = hfs_ext_write_extent(inode);
> > +??? if (res)
> > +??? ??? return res;
> >
> > ??? if (inode->i_ino <
> HFS_FIRSTUSER_CNID) {
> > ??? ??? switch
> (inode->i_ino) {
> > @@ -515,7 +518,11 @@ static struct dentry
> *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
> > ??? if (!inode)
> > ??? ??? return
> ERR_PTR(-ENOMEM);
> >
> > -???
> hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> > +??? if (res) {
> > +??? ??? iput(inode);
> > +??? ??? return
> ERR_PTR(res);
> > +??? }
> > ??? fd.search_key->cat =
> HFS_I(dir)->cat_key;
> > ??? res = hfs_brec_read(&fd,
> &rec, sizeof(rec));
> > ??? if (!res) {
> > diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> > index bbaaa8a..719760b 100644
> > --- a/fs/hfs/super.c
> > +++ b/fs/hfs/super.c
> > @@ -418,7 +418,9 @@ static int hfs_fill_super(struct
> super_block *sb, void *data, int silent)
> > ??? }
> >
> > ??? /* try to get the root inode */
> > -???
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? res =
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> > +??? if (res)
> > +??? ??? goto
> bail_no_root;
> > ??? res = hfs_cat_find_brec(sb,
> HFS_ROOT_CNID, &fd);
> > ??? if (!res) {
> > ??? ??? if
> (fd.entrylength > sizeof(rec) || fd.entrylength < 0)
> {
> > --
> > 1.7.9.5
> >
> > --
> > To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at? http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at? http://www.tux.org/lkml/
>
>

2013-04-06 21:13:38

by Alexey Khoroshilov

[permalink] [raw]
Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()

Hi Vyacheslav,

On 03/30/2013 03:35 PM, Vyacheslav Dubeyko wrote:
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <[email protected]>
>> ---
>> fs/hfs/catalog.c | 12 +++++++++---
>> fs/hfs/dir.c | 8 ++++++--
>> fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
>> fs/hfs/hfs_fs.h | 2 +-
>> fs/hfs/inode.c | 11 +++++++++--
>> fs/hfs/super.c | 4 +++-
>> 6 files changed, 61 insertions(+), 24 deletions(-)
>>
>> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
>> index 424b033..9569b39 100644
>> --- a/fs/hfs/catalog.c
>> +++ b/fs/hfs/catalog.c
>> @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
>> return -ENOSPC;
>>
>> sb = dir->i_sb;
>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + if (err)
>> + return err;
>>
>> hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
>> entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
>> @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
>>
>> dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
>> sb = dir->i_sb;
>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + if (res)
>> + return res;
>>
>> hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
>> res = hfs_brec_find(&fd);
>> @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
>> dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
>> dst_dir->i_ino, dst_name->name);
>> sb = src_dir->i_sb;
>> - hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>> + if (err)
>> + return err;
>> dst_fd = src_fd;
>>
>> /* find the old dir entry and read the data */
>> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
>> index 5f7f1ab..e1c8048 100644
>> --- a/fs/hfs/dir.c
>> +++ b/fs/hfs/dir.c
>> @@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
>> struct inode *inode = NULL;
>> int res;
>>
>> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>> + if (res)
>> + return ERR_PTR(res);
>> hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
>> res = hfs_brec_read(&fd, &rec, sizeof(rec));
>> if (res) {
>> @@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
>> if (filp->f_pos >= inode->i_size)
>> return 0;
>>
>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> + if (err)
>> + return err;
>> hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
>> err = hfs_brec_find(&fd);
>> if (err)
>> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
>> index a67955a..813447b 100644
>> --- a/fs/hfs/extent.c
>> +++ b/fs/hfs/extent.c
>> @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
>> return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
>> }
>>
>> -static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>> +static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>> {
>> int res;
>>
>> @@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
>> res = hfs_brec_find(fd);
>> if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
>> if (res != -ENOENT)
>> - return;
>> + return res;
>> hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
>> HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
>> } else {
>> if (res)
>> - return;
>> + return res;
>> hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
>> HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
>> }
>> + return 0;
>> }
> As I see, this fix makes sense and for hfsplus also. Please, make it and for hfsplus.
Sorry, I did not catch which fix do you mean. Could you please clarify it.

Thank you,
Alexey

2013-04-07 09:32:08

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()

Hi Alexey,

On Apr 7, 2013, at 1:13 AM, Alexey Khoroshilov wrote:

> Hi Vyacheslav,
>
> On 03/30/2013 03:35 PM, Vyacheslav Dubeyko wrote:
>>> Found by Linux Driver Verification project (linuxtesting.org).
>>>
>>> Signed-off-by: Alexey Khoroshilov <[email protected]>
>>> ---
>>> fs/hfs/catalog.c | 12 +++++++++---
>>> fs/hfs/dir.c | 8 ++++++--
>>> fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
>>> fs/hfs/hfs_fs.h | 2 +-
>>> fs/hfs/inode.c | 11 +++++++++--
>>> fs/hfs/super.c | 4 +++-
>>> 6 files changed, 61 insertions(+), 24 deletions(-)
>>>
>>> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
>>> index 424b033..9569b39 100644
>>> --- a/fs/hfs/catalog.c
>>> +++ b/fs/hfs/catalog.c
>>> @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
>>> return -ENOSPC;
>>>
>>> sb = dir->i_sb;
>>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + if (err)
>>> + return err;
>>>
>>> hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
>>> entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
>>> @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
>>>
>>> dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
>>> sb = dir->i_sb;
>>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + if (res)
>>> + return res;
>>>
>>> hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
>>> res = hfs_brec_find(&fd);
>>> @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
>>> dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
>>> dst_dir->i_ino, dst_name->name);
>>> sb = src_dir->i_sb;
>>> - hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>>> + if (err)
>>> + return err;
>>> dst_fd = src_fd;
>>>
>>> /* find the old dir entry and read the data */
>>> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
>>> index 5f7f1ab..e1c8048 100644
>>> --- a/fs/hfs/dir.c
>>> +++ b/fs/hfs/dir.c
>>> @@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
>>> struct inode *inode = NULL;
>>> int res;
>>>
>>> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>>> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>>> + if (res)
>>> + return ERR_PTR(res);
>>> hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
>>> res = hfs_brec_read(&fd, &rec, sizeof(rec));
>>> if (res) {
>>> @@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
>>> if (filp->f_pos >= inode->i_size)
>>> return 0;
>>>
>>> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>>> + if (err)
>>> + return err;
>>> hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
>>> err = hfs_brec_find(&fd);
>>> if (err)
>>> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
>>> index a67955a..813447b 100644
>>> --- a/fs/hfs/extent.c
>>> +++ b/fs/hfs/extent.c
>>> @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
>>> return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
>>> }
>>>
>>> -static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>>> +static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>>> {
>>> int res;
>>>
>>> @@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
>>> res = hfs_brec_find(fd);
>>> if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
>>> if (res != -ENOENT)
>>> - return;
>>> + return res;
>>> hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
>>> HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
>>> } else {
>>> if (res)
>>> - return;
>>> + return res;
>>> hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
>>> HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
>>> }
>>> + return 0;
>>> }
>> As I see, this fix makes sense and for hfsplus also. Please, make it and for hfsplus.
> Sorry, I did not catch which fix do you mean. Could you please clarify it.
>

I meant:
(1) correction the issue with returning error in __hfsplus_ext_write_extent() method (http://lxr.free-electrons.com/source/fs/hfsplus/extents.c#L86);
(2) adding error processing in hfsplus_ext_write_extent_locked() method (http://lxr.free-electrons.com/source/fs/hfsplus/extents.c#L132);
(3) adding error processing in __hfsplus_ext_cache_extent() method (http://lxr.free-electrons.com/source/fs/hfsplus/extents.c#L179).

Moreover, as I remember, Hin-Tak asks about adding dprint messages.

Thanks,
Vyacheslav Dubeyko.

> Thank you,
> Alexey
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-04-07 21:22:09

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH 1/2] hfsplus: add error propagation to __hfsplus_ext_write_extent()

__hfsplus_ext_write_extent() suppresses errors coming from hfs_brec_find().
The patch implements error code propagation.

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
fs/hfsplus/extents.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index a94f0f7..fed73f7 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -83,7 +83,7 @@ static u32 hfsplus_ext_lastblock(struct hfsplus_extent *ext)
return be32_to_cpu(ext->start_block) + be32_to_cpu(ext->block_count);
}

-static void __hfsplus_ext_write_extent(struct inode *inode,
+static int __hfsplus_ext_write_extent(struct inode *inode,
struct hfs_find_data *fd)
{
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
@@ -98,13 +98,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
res = hfs_brec_find(fd, hfs_find_rec_by_key);
if (hip->extent_state & HFSPLUS_EXT_NEW) {
if (res != -ENOENT)
- return;
+ return res;
hfs_brec_insert(fd, hip->cached_extents,
sizeof(hfsplus_extent_rec));
hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
} else {
if (res)
- return;
+ return res;
hfs_bnode_write(fd->bnode, hip->cached_extents,
fd->entryoffset, fd->entrylength);
hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
@@ -117,11 +117,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
* to explicily mark the inode dirty, too.
*/
set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
+
+ return 0;
}

static int hfsplus_ext_write_extent_locked(struct inode *inode)
{
- int res;
+ int res = 0;

if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
struct hfs_find_data fd;
@@ -129,10 +131,10 @@ static int hfsplus_ext_write_extent_locked(struct inode *inode)
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
if (res)
return res;
- __hfsplus_ext_write_extent(inode, &fd);
+ res = __hfsplus_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
- return 0;
+ return res;
}

int hfsplus_ext_write_extent(struct inode *inode)
@@ -175,8 +177,11 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd,

WARN_ON(!mutex_is_locked(&hip->extents_lock));

- if (hip->extent_state & HFSPLUS_EXT_DIRTY)
- __hfsplus_ext_write_extent(inode, fd);
+ if (hip->extent_state & HFSPLUS_EXT_DIRTY) {
+ res = __hfsplus_ext_write_extent(inode, fd);
+ if (res)
+ return res;
+ }

res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
block, HFSPLUS_IS_RSRC(inode) ?
--
1.7.9.5

2013-04-07 21:22:17

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH 2/2] hfsplus: add printk to log allocation failure in hfs_find_init()

Add printk to log allocation failure in hfs_find_init(),
"so that there is a sign in dmesg when the error condition is triggered".
(per Hin-Tak Leung request)

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
fs/hfsplus/bfind.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index d73c98d..067ddb5 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -18,8 +18,10 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
fd->tree = tree;
fd->bnode = NULL;
ptr = kmalloc(tree->max_key_len * 2 + 4, GFP_KERNEL);
- if (!ptr)
+ if (!ptr) {
+ printk(KERN_ERR "hfs: allocation failed in hfs_find_init()\n");
return -ENOMEM;
+ }
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n",
--
1.7.9.5

2013-04-07 22:00:21

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 2/2] hfsplus: add printk to log allocation failure in hfs_find_init()

On Mon, 2013-04-08 at 01:21 +0400, Alexey Khoroshilov wrote:
> Add printk to log allocation failure in hfs_find_init(),
> "so that there is a sign in dmesg when the error condition is triggered".
> (per Hin-Tak Leung request)

Not needed. There already is a generic dump_stack
on all allocation failures without __GFP_NOWARN.

> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
[]
> @@ -18,8 +18,10 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)

> + if (!ptr) {
> + printk(KERN_ERR "hfs: allocation failed in hfs_find_init()\n");
> return -ENOMEM;

2013-04-08 05:55:48

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfsplus: add error propagation to __hfsplus_ext_write_extent()

Hi Alexey,

On Mon, 2013-04-08 at 01:21 +0400, Alexey Khoroshilov wrote:
> __hfsplus_ext_write_extent() suppresses errors coming from hfs_brec_find().
> The patch implements error code propagation.
>

Please, prepare a single patch set for all your changes in HFS and HFS+. These changes are related to each other, so, it makes sense in one patch set.

Thanks,
Vyacheslav Dubeyko.

> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---
> fs/hfsplus/extents.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
> index a94f0f7..fed73f7 100644
> --- a/fs/hfsplus/extents.c
> +++ b/fs/hfsplus/extents.c
> @@ -83,7 +83,7 @@ static u32 hfsplus_ext_lastblock(struct hfsplus_extent *ext)
> return be32_to_cpu(ext->start_block) + be32_to_cpu(ext->block_count);
> }
>
> -static void __hfsplus_ext_write_extent(struct inode *inode,
> +static int __hfsplus_ext_write_extent(struct inode *inode,
> struct hfs_find_data *fd)
> {
> struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
> @@ -98,13 +98,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
> res = hfs_brec_find(fd, hfs_find_rec_by_key);
> if (hip->extent_state & HFSPLUS_EXT_NEW) {
> if (res != -ENOENT)
> - return;
> + return res;
> hfs_brec_insert(fd, hip->cached_extents,
> sizeof(hfsplus_extent_rec));
> hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
> } else {
> if (res)
> - return;
> + return res;
> hfs_bnode_write(fd->bnode, hip->cached_extents,
> fd->entryoffset, fd->entrylength);
> hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
> @@ -117,11 +117,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
> * to explicily mark the inode dirty, too.
> */
> set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
> +
> + return 0;
> }
>
> static int hfsplus_ext_write_extent_locked(struct inode *inode)
> {
> - int res;
> + int res = 0;
>
> if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
> struct hfs_find_data fd;
> @@ -129,10 +131,10 @@ static int hfsplus_ext_write_extent_locked(struct inode *inode)
> res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
> if (res)
> return res;
> - __hfsplus_ext_write_extent(inode, &fd);
> + res = __hfsplus_ext_write_extent(inode, &fd);
> hfs_find_exit(&fd);
> }
> - return 0;
> + return res;
> }
>
> int hfsplus_ext_write_extent(struct inode *inode)
> @@ -175,8 +177,11 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd,
>
> WARN_ON(!mutex_is_locked(&hip->extents_lock));
>
> - if (hip->extent_state & HFSPLUS_EXT_DIRTY)
> - __hfsplus_ext_write_extent(inode, fd);
> + if (hip->extent_state & HFSPLUS_EXT_DIRTY) {
> + res = __hfsplus_ext_write_extent(inode, fd);
> + if (res)
> + return res;
> + }
>
> res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
> block, HFSPLUS_IS_RSRC(inode) ?

2013-04-08 06:08:47

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 2/2] hfsplus: add printk to log allocation failure in hfs_find_init()

On Sun, 2013-04-07 at 15:00 -0700, Joe Perches wrote:
> On Mon, 2013-04-08 at 01:21 +0400, Alexey Khoroshilov wrote:
> > Add printk to log allocation failure in hfs_find_init(),
> > "so that there is a sign in dmesg when the error condition is triggered".
> > (per Hin-Tak Leung request)
>
> Not needed. There already is a generic dump_stack
> on all allocation failures without __GFP_NOWARN.
>

I agree too.

Moreover, Hin-Tak asks about dprint() but not printk(). The dprint()
messages can be useful for debugging purposes and will be disabled for
usual kernel build.

I think that adding dprint() messages in hfs_find_init() is not
necessary. But adding dprint() for __hfsplus_ext_write_extent() and
other places can be useful, from my point of view. And such messages can
be useful as for HFS+ as for HFS drivers.

With the best regards,
Vyacheslav Dubeyko.

> > diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> []
> > @@ -18,8 +18,10 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
>
> > + if (!ptr) {
> > + printk(KERN_ERR "hfs: allocation failed in hfs_find_init()\n");
> > return -ENOMEM;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-04-08 16:37:50

by Joe Perches

[permalink] [raw]
Subject: [PATCH 0/2] hfs/hfsplus: Modernize logging styles

Joe Perches (2):
hfs/hfsplus: Convert dprint to hfs_dbg
hfs/hfsplus: Convert printks to pr_<level>

fs/hfs/bfind.c | 10 +++++----
fs/hfs/bitmap.c | 4 ++--
fs/hfs/bnode.c | 39 ++++++++++++++++++----------------
fs/hfs/brec.c | 19 +++++++++--------
fs/hfs/btree.c | 31 ++++++++++++++-------------
fs/hfs/catalog.c | 12 ++++++-----
fs/hfs/dir.c | 12 +++++------
fs/hfs/extent.c | 20 ++++++++++--------
fs/hfs/hfs_fs.h | 20 ++++++++++++++++--
fs/hfs/inode.c | 4 ++--
fs/hfs/mdb.c | 23 ++++++++++----------
fs/hfs/super.c | 43 +++++++++++++++++++------------------
fs/hfsplus/attributes.c | 26 +++++++++++------------
fs/hfsplus/bfind.c | 6 +++---
fs/hfsplus/bitmap.c | 12 +++++------
fs/hfsplus/bnode.c | 36 +++++++++++++++----------------
fs/hfsplus/brec.c | 14 ++++++-------
fs/hfsplus/btree.c | 29 +++++++++++++------------
fs/hfsplus/catalog.c | 11 +++++-----
fs/hfsplus/dir.c | 14 ++++++-------
fs/hfsplus/extents.c | 32 ++++++++++++++--------------
fs/hfsplus/hfsplus_fs.h | 20 +++++++++++++++---
fs/hfsplus/inode.c | 4 ++--
fs/hfsplus/options.c | 22 +++++++++----------
fs/hfsplus/super.c | 56 +++++++++++++++++++------------------------------
fs/hfsplus/wrapper.c | 8 +++----
fs/hfsplus/xattr.c | 41 ++++++++++++++++++------------------
27 files changed, 296 insertions(+), 272 deletions(-)

--
1.8.1.2.459.gbcd45b4.dirty

2013-04-08 16:38:06

by Joe Perches

[permalink] [raw]
Subject: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

Use a more current logging style.

Rename macro and uses.
Add do {} while (0) to macro.
Add DBG_ to macro.
Add and use hfs_dbg_cont variant where appropriate.

Signed-off-by: Joe Perches <[email protected]>
---
fs/hfs/bfind.c | 6 ++++--
fs/hfs/bitmap.c | 4 ++--
fs/hfs/bnode.c | 35 +++++++++++++++++++----------------
fs/hfs/brec.c | 11 +++++++----
fs/hfs/btree.c | 2 +-
fs/hfs/catalog.c | 8 +++++---
fs/hfs/extent.c | 20 +++++++++++---------
fs/hfs/hfs_fs.h | 14 ++++++++++++--
fs/hfs/inode.c | 4 ++--
fs/hfsplus/attributes.c | 8 ++++----
fs/hfsplus/bfind.c | 4 ++--
fs/hfsplus/bitmap.c | 10 +++++-----
fs/hfsplus/bnode.c | 30 +++++++++++++++---------------
fs/hfsplus/brec.c | 10 +++++-----
fs/hfsplus/btree.c | 4 ++--
fs/hfsplus/catalog.c | 7 +++----
fs/hfsplus/extents.c | 26 +++++++++++++-------------
fs/hfsplus/hfsplus_fs.h | 14 +++++++++++---
fs/hfsplus/super.c | 8 ++++----
19 files changed, 127 insertions(+), 98 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index 571abe9..e928f6c 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -22,7 +22,8 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
return -ENOMEM;
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
- dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
+ hfs_dbg(BNODE_REFS, "find_init: %d (%p)\n",
+ tree->cnid, __builtin_return_address(0));
mutex_lock(&tree->tree_lock);
return 0;
}
@@ -31,7 +32,8 @@ void hfs_find_exit(struct hfs_find_data *fd)
{
hfs_bnode_put(fd->bnode);
kfree(fd->search_key);
- dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
+ hfs_dbg(BNODE_REFS, "find_exit: %d (%p)\n",
+ fd->tree->cnid, __builtin_return_address(0));
mutex_unlock(&fd->tree->tree_lock);
fd->tree = NULL;
}
diff --git a/fs/hfs/bitmap.c b/fs/hfs/bitmap.c
index c6e9736..28307bc 100644
--- a/fs/hfs/bitmap.c
+++ b/fs/hfs/bitmap.c
@@ -158,7 +158,7 @@ u32 hfs_vbm_search_free(struct super_block *sb, u32 goal, u32 *num_bits)
}
}

- dprint(DBG_BITMAP, "alloc_bits: %u,%u\n", pos, *num_bits);
+ hfs_dbg(BITMAP, "alloc_bits: %u,%u\n", pos, *num_bits);
HFS_SB(sb)->free_ablocks -= *num_bits;
hfs_bitmap_dirty(sb);
out:
@@ -200,7 +200,7 @@ int hfs_clear_vbm_bits(struct super_block *sb, u16 start, u16 count)
if (!count)
return 0;

- dprint(DBG_BITMAP, "clear_bits: %u,%u\n", start, count);
+ hfs_dbg(BITMAP, "clear_bits: %u,%u\n", start, count);
/* are all of the bits in range? */
if ((start + count) > HFS_SB(sb)->fs_ablocks)
return -2;
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index cdb41a1..8693919 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -100,7 +100,7 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
struct hfs_btree *tree;
struct page *src_page, *dst_page;

- dprint(DBG_BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
+ hfs_dbg(BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
if (!len)
return;
tree = src_node->tree;
@@ -120,7 +120,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
struct page *page;
void *ptr;

- dprint(DBG_BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
+ hfs_dbg(BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
if (!len)
return;
src += node->page_offset;
@@ -138,16 +138,16 @@ void hfs_bnode_dump(struct hfs_bnode *node)
__be32 cnid;
int i, off, key_off;

- dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this);
+ hfs_dbg(BNODE_MOD, "bnode: %d\n", node->this);
hfs_bnode_read(node, &desc, 0, sizeof(desc));
- dprint(DBG_BNODE_MOD, "%d, %d, %d, %d, %d\n",
+ hfs_dbg(BNODE_MOD, "%d, %d, %d, %d, %d\n",
be32_to_cpu(desc.next), be32_to_cpu(desc.prev),
desc.type, desc.height, be16_to_cpu(desc.num_recs));

off = node->tree->node_size - 2;
for (i = be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
key_off = hfs_bnode_read_u16(node, off);
- dprint(DBG_BNODE_MOD, " %d", key_off);
+ hfs_dbg_cont(BNODE_MOD, " %d", key_off);
if (i && node->type == HFS_NODE_INDEX) {
int tmp;

@@ -155,17 +155,18 @@ void hfs_bnode_dump(struct hfs_bnode *node)
tmp = (hfs_bnode_read_u8(node, key_off) | 1) + 1;
else
tmp = node->tree->max_key_len + 1;
- dprint(DBG_BNODE_MOD, " (%d,%d", tmp, hfs_bnode_read_u8(node, key_off));
+ hfs_dbg_cont(BNODE_MOD, " (%d,%d",
+ tmp, hfs_bnode_read_u8(node, key_off));
hfs_bnode_read(node, &cnid, key_off + tmp, 4);
- dprint(DBG_BNODE_MOD, ",%d)", be32_to_cpu(cnid));
+ hfs_dbg_cont(BNODE_MOD, ",%d)", be32_to_cpu(cnid));
} else if (i && node->type == HFS_NODE_LEAF) {
int tmp;

tmp = hfs_bnode_read_u8(node, key_off);
- dprint(DBG_BNODE_MOD, " (%d)", tmp);
+ hfs_dbg_cont(BNODE_MOD, " (%d)", tmp);
}
}
- dprint(DBG_BNODE_MOD, "\n");
+ hfs_dbg_cont(BNODE_MOD, "\n");
}

void hfs_bnode_unlink(struct hfs_bnode *node)
@@ -257,8 +258,8 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
node->this = cnid;
set_bit(HFS_BNODE_NEW, &node->flags);
atomic_set(&node->refcnt, 1);
- dprint(DBG_BNODE_REFS, "new_node(%d:%d): 1\n",
- node->tree->cnid, node->this);
+ hfs_dbg(BNODE_REFS, "new_node(%d:%d): 1\n",
+ node->tree->cnid, node->this);
init_waitqueue_head(&node->lock_wq);
spin_lock(&tree->hash_lock);
node2 = hfs_bnode_findhash(tree, cnid);
@@ -301,7 +302,7 @@ void hfs_bnode_unhash(struct hfs_bnode *node)
{
struct hfs_bnode **p;

- dprint(DBG_BNODE_REFS, "remove_node(%d:%d): %d\n",
+ hfs_dbg(BNODE_REFS, "remove_node(%d:%d): %d\n",
node->tree->cnid, node->this, atomic_read(&node->refcnt));
for (p = &node->tree->node_hash[hfs_bnode_hash(node->this)];
*p && *p != node; p = &(*p)->next_hash)
@@ -443,8 +444,9 @@ void hfs_bnode_get(struct hfs_bnode *node)
{
if (node) {
atomic_inc(&node->refcnt);
- dprint(DBG_BNODE_REFS, "get_node(%d:%d): %d\n",
- node->tree->cnid, node->this, atomic_read(&node->refcnt));
+ hfs_dbg(BNODE_REFS, "get_node(%d:%d): %d\n",
+ node->tree->cnid, node->this,
+ atomic_read(&node->refcnt));
}
}

@@ -455,8 +457,9 @@ void hfs_bnode_put(struct hfs_bnode *node)
struct hfs_btree *tree = node->tree;
int i;

- dprint(DBG_BNODE_REFS, "put_node(%d:%d): %d\n",
- node->tree->cnid, node->this, atomic_read(&node->refcnt));
+ hfs_dbg(BNODE_REFS, "put_node(%d:%d): %d\n",
+ node->tree->cnid, node->this,
+ atomic_read(&node->refcnt));
BUG_ON(!atomic_read(&node->refcnt));
if (!atomic_dec_and_lock(&node->refcnt, &tree->hash_lock))
return;
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 92fb358..5764257 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -94,7 +94,8 @@ again:
end_rec_off = tree->node_size - (node->num_recs + 1) * 2;
end_off = hfs_bnode_read_u16(node, end_rec_off);
end_rec_off -= 2;
- dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n", rec, size, end_off, end_rec_off);
+ hfs_dbg(BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
+ rec, size, end_off, end_rec_off);
if (size > end_rec_off - end_off) {
if (new_node)
panic("not enough room!\n");
@@ -190,7 +191,8 @@ again:
mark_inode_dirty(tree->inode);
}
hfs_bnode_dump(node);
- dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n", fd->record, fd->keylength + fd->entrylength);
+ hfs_dbg(BNODE_MOD, "remove_rec: %d, %d\n",
+ fd->record, fd->keylength + fd->entrylength);
if (!--node->num_recs) {
hfs_bnode_unlink(node);
if (!node->parent)
@@ -240,7 +242,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
if (IS_ERR(new_node))
return new_node;
hfs_bnode_get(node);
- dprint(DBG_BNODE_MOD, "split_nodes: %d - %d - %d\n",
+ hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n",
node->this, new_node->this, node->next);
new_node->next = node->next;
new_node->prev = node->this;
@@ -374,7 +376,8 @@ again:
newkeylen = (hfs_bnode_read_u8(node, 14) | 1) + 1;
else
fd->keylength = newkeylen = tree->max_key_len + 1;
- dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n", rec, fd->keylength, newkeylen);
+ hfs_dbg(BNODE_MOD, "update_rec: %d, %d, %d\n",
+ rec, fd->keylength, newkeylen);

rec_off = tree->node_size - (rec + 2) * 2;
end_rec_off = tree->node_size - (parent->num_recs + 1) * 2;
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 1cbdeea..07d94ce 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -316,7 +316,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
u32 nidx;
u8 *data, byte, m;

- dprint(DBG_BNODE_MOD, "btree_free_node: %u\n", node->this);
+ hfs_dbg(BNODE_MOD, "btree_free_node: %u\n", node->this);
tree = node->tree;
nidx = node->this;
node = hfs_bnode_find(tree, 0);
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 424b033..76cfb17 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -87,7 +87,8 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
int entry_size;
int err;

- dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n", str->name, cnid, inode->i_nlink);
+ hfs_dbg(CAT_MOD, "create_cat: %s,%u(%d)\n",
+ str->name, cnid, inode->i_nlink);
if (dir->i_size >= HFS_MAX_VALENCE)
return -ENOSPC;

@@ -212,7 +213,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
struct list_head *pos;
int res, type;

- dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
+ hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
sb = dir->i_sb;
hfs_find_init(HFS_SB(sb)->cat_tree, &fd);

@@ -278,7 +279,8 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
int entry_size, type;
int err;

- dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
+ hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
+ cnid, src_dir->i_ino, src_name->name,
dst_dir->i_ino, dst_name->name);
sb = src_dir->i_sb;
hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index a67955a..6e63a4d 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -195,11 +195,12 @@ static void hfs_dump_extent(struct hfs_extent *extent)
{
int i;

- dprint(DBG_EXTENT, " ");
+ hfs_dbg(EXTENT, " ");
for (i = 0; i < 3; i++)
- dprint(DBG_EXTENT, " %u:%u", be16_to_cpu(extent[i].block),
- be16_to_cpu(extent[i].count));
- dprint(DBG_EXTENT, "\n");
+ hfs_dbg_cont(EXTENT, " %u:%u",
+ be16_to_cpu(extent[i].block),
+ be16_to_cpu(extent[i].count));
+ hfs_dbg_cont(EXTENT, "\n");
}

static int hfs_add_extent(struct hfs_extent *extent, u16 offset,
@@ -392,10 +393,10 @@ int hfs_extend_file(struct inode *inode)
goto out;
}

- dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
+ hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
if (HFS_I(inode)->alloc_blocks == HFS_I(inode)->first_blocks) {
if (!HFS_I(inode)->first_blocks) {
- dprint(DBG_EXTENT, "first extents\n");
+ hfs_dbg(EXTENT, "first extents\n");
/* no extents yet */
HFS_I(inode)->first_extents[0].block = cpu_to_be16(start);
HFS_I(inode)->first_extents[0].count = cpu_to_be16(len);
@@ -437,7 +438,7 @@ out:
return res;

insert_extent:
- dprint(DBG_EXTENT, "insert new extent\n");
+ hfs_dbg(EXTENT, "insert new extent\n");
hfs_ext_write_extent(inode);

memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
@@ -460,8 +461,9 @@ void hfs_file_truncate(struct inode *inode)
u32 size;
int res;

- dprint(DBG_INODE, "truncate: %lu, %Lu -> %Lu\n", inode->i_ino,
- (long long)HFS_I(inode)->phys_size, inode->i_size);
+ hfs_dbg(INODE, "truncate: %lu, %Lu -> %Lu\n",
+ inode->i_ino, (long long)HFS_I(inode)->phys_size,
+ inode->i_size);
if (inode->i_size > HFS_I(inode)->phys_size) {
struct address_space *mapping = inode->i_mapping;
void *fsdata;
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 693df9f..cf088e0 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -34,8 +34,18 @@
//#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
#define DBG_MASK (0)

-#define dprint(flg, fmt, args...) \
- if (flg & DBG_MASK) printk(fmt , ## args)
+#define hfs_dbg(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
+} while (0)
+
+#define hfs_dbg_cont(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_CONT fmt, ##__VA_ARGS__); \
+} while (0)
+

/*
* struct hfs_inode_info
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index a9d60d4..d999db7 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -238,7 +238,7 @@ void hfs_delete_inode(struct inode *inode)
{
struct super_block *sb = inode->i_sb;

- dprint(DBG_INODE, "delete_inode: %lu\n", inode->i_ino);
+ hfs_dbg(INODE, "delete_inode: %lu\n", inode->i_ino);
if (S_ISDIR(inode->i_mode)) {
HFS_SB(sb)->folder_count--;
if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
@@ -418,7 +418,7 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
struct hfs_find_data fd;
hfs_cat_rec rec;

- dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
+ hfs_dbg(INODE, "hfs_write_inode: %lu\n", inode->i_ino);
hfs_ext_write_extent(inode);

if (inode->i_ino < HFS_FIRSTUSER_CNID) {
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index 8d691f1..2043b50 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -166,7 +166,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
{
int err = 0;

- dprint(DBG_ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);
+ hfs_dbg(ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);

if (!HFSPLUS_SB(sb)->attr_tree) {
printk(KERN_ERR "hfs: attributes file doesn't exist\n");
@@ -228,7 +228,7 @@ int hfsplus_create_attr(struct inode *inode,
int entry_size;
int err;

- dprint(DBG_ATTR_MOD, "create_attr: %s,%ld\n",
+ hfs_dbg(ATTR_MOD, "create_attr: %s,%ld\n",
name ? name : NULL, inode->i_ino);

if (!HFSPLUS_SB(sb)->attr_tree) {
@@ -328,7 +328,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
struct super_block *sb = inode->i_sb;
struct hfs_find_data fd;

- dprint(DBG_ATTR_MOD, "delete_attr: %s,%ld\n",
+ hfs_dbg(ATTR_MOD, "delete_attr: %s,%ld\n",
name ? name : NULL, inode->i_ino);

if (!HFSPLUS_SB(sb)->attr_tree) {
@@ -369,7 +369,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
int err = 0;
struct hfs_find_data fd;

- dprint(DBG_ATTR_MOD, "delete_all_attrs: %d\n", cnid);
+ hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);

if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
printk(KERN_ERR "hfs: attributes file doesn't exist\n");
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index bbfdc17..d27f37f 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -22,7 +22,7 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
return -ENOMEM;
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
- dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n",
+ hfs_dbg(BNODE_REFS, "find_init: %d (%p)\n",
tree->cnid, __builtin_return_address(0));
switch (tree->cnid) {
case HFSPLUS_CAT_CNID:
@@ -44,7 +44,7 @@ void hfs_find_exit(struct hfs_find_data *fd)
{
hfs_bnode_put(fd->bnode);
kfree(fd->search_key);
- dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n",
+ hfs_dbg(BNODE_REFS, "find_exit: %d (%p)\n",
fd->tree->cnid, __builtin_return_address(0));
mutex_unlock(&fd->tree->tree_lock);
fd->tree = NULL;
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index 6feefc0..7da6d46 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -30,7 +30,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size,
if (!len)
return size;

- dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
+ hfs_dbg(BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
mutex_lock(&sbi->alloc_mutex);
mapping = sbi->alloc_file->i_mapping;
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
@@ -89,14 +89,14 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size,
else
end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32;
}
- dprint(DBG_BITMAP, "bitmap full\n");
+ hfs_dbg(BITMAP, "bitmap full\n");
start = size;
goto out;

found:
start = offset + (curr - pptr) * 32 + i;
if (start >= size) {
- dprint(DBG_BITMAP, "bitmap full\n");
+ hfs_dbg(BITMAP, "bitmap full\n");
goto out;
}
/* do any partial u32 at the start */
@@ -154,7 +154,7 @@ done:
*max = offset + (curr - pptr) * 32 + i - start;
sbi->free_blocks -= *max;
hfsplus_mark_mdb_dirty(sb);
- dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
+ hfs_dbg(BITMAP, "-> %u,%u\n", start, *max);
out:
mutex_unlock(&sbi->alloc_mutex);
return start;
@@ -173,7 +173,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
if (!count)
return 0;

- dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
+ hfs_dbg(BITMAP, "block_free: %u,%u\n", offset, count);
/* are all of the bits in range? */
if ((offset + count) > sbi->total_blocks)
return -ENOENT;
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index f31ac6f..1ca9304 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -130,7 +130,7 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
struct page **src_page, **dst_page;
int l;

- dprint(DBG_BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
+ hfs_dbg(BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
if (!len)
return;
tree = src_node->tree;
@@ -188,7 +188,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
struct page **src_page, **dst_page;
int l;

- dprint(DBG_BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
+ hfs_dbg(BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
if (!len)
return;
src += node->page_offset;
@@ -302,16 +302,16 @@ void hfs_bnode_dump(struct hfs_bnode *node)
__be32 cnid;
int i, off, key_off;

- dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this);
+ hfs_dbg(BNODE_MOD, "bnode: %d\n", node->this);
hfs_bnode_read(node, &desc, 0, sizeof(desc));
- dprint(DBG_BNODE_MOD, "%d, %d, %d, %d, %d\n",
+ hfs_dbg(BNODE_MOD, "%d, %d, %d, %d, %d\n",
be32_to_cpu(desc.next), be32_to_cpu(desc.prev),
desc.type, desc.height, be16_to_cpu(desc.num_recs));

off = node->tree->node_size - 2;
for (i = be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
key_off = hfs_bnode_read_u16(node, off);
- dprint(DBG_BNODE_MOD, " %d", key_off);
+ hfs_dbg(BNODE_MOD, " %d", key_off);
if (i && node->type == HFS_NODE_INDEX) {
int tmp;

@@ -320,17 +320,17 @@ void hfs_bnode_dump(struct hfs_bnode *node)
tmp = hfs_bnode_read_u16(node, key_off) + 2;
else
tmp = node->tree->max_key_len + 2;
- dprint(DBG_BNODE_MOD, " (%d", tmp);
+ hfs_dbg_cont(BNODE_MOD, " (%d", tmp);
hfs_bnode_read(node, &cnid, key_off + tmp, 4);
- dprint(DBG_BNODE_MOD, ",%d)", be32_to_cpu(cnid));
+ hfs_dbg_cont(BNODE_MOD, ",%d)", be32_to_cpu(cnid));
} else if (i && node->type == HFS_NODE_LEAF) {
int tmp;

tmp = hfs_bnode_read_u16(node, key_off);
- dprint(DBG_BNODE_MOD, " (%d)", tmp);
+ hfs_dbg_cont(BNODE_MOD, " (%d)", tmp);
}
}
- dprint(DBG_BNODE_MOD, "\n");
+ hfs_dbg_cont(BNODE_MOD, "\n");
}

void hfs_bnode_unlink(struct hfs_bnode *node)
@@ -366,7 +366,7 @@ void hfs_bnode_unlink(struct hfs_bnode *node)

/* move down? */
if (!node->prev && !node->next)
- dprint(DBG_BNODE_MOD, "hfs_btree_del_level\n");
+ hfs_dbg(BNODE_MOD, "hfs_btree_del_level\n");
if (!node->parent) {
tree->root = 0;
tree->depth = 0;
@@ -425,8 +425,8 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
node->this = cnid;
set_bit(HFS_BNODE_NEW, &node->flags);
atomic_set(&node->refcnt, 1);
- dprint(DBG_BNODE_REFS, "new_node(%d:%d): 1\n",
- node->tree->cnid, node->this);
+ hfs_dbg(BNODE_REFS, "new_node(%d:%d): 1\n",
+ node->tree->cnid, node->this);
init_waitqueue_head(&node->lock_wq);
spin_lock(&tree->hash_lock);
node2 = hfs_bnode_findhash(tree, cnid);
@@ -470,7 +470,7 @@ void hfs_bnode_unhash(struct hfs_bnode *node)
{
struct hfs_bnode **p;

- dprint(DBG_BNODE_REFS, "remove_node(%d:%d): %d\n",
+ hfs_dbg(BNODE_REFS, "remove_node(%d:%d): %d\n",
node->tree->cnid, node->this, atomic_read(&node->refcnt));
for (p = &node->tree->node_hash[hfs_bnode_hash(node->this)];
*p && *p != node; p = &(*p)->next_hash)
@@ -620,7 +620,7 @@ void hfs_bnode_get(struct hfs_bnode *node)
{
if (node) {
atomic_inc(&node->refcnt);
- dprint(DBG_BNODE_REFS, "get_node(%d:%d): %d\n",
+ hfs_dbg(BNODE_REFS, "get_node(%d:%d): %d\n",
node->tree->cnid, node->this,
atomic_read(&node->refcnt));
}
@@ -633,7 +633,7 @@ void hfs_bnode_put(struct hfs_bnode *node)
struct hfs_btree *tree = node->tree;
int i;

- dprint(DBG_BNODE_REFS, "put_node(%d:%d): %d\n",
+ hfs_dbg(BNODE_REFS, "put_node(%d:%d): %d\n",
node->tree->cnid, node->this,
atomic_read(&node->refcnt));
BUG_ON(!atomic_read(&node->refcnt));
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 298d4e4..e238ba8 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -90,7 +90,7 @@ again:
end_rec_off = tree->node_size - (node->num_recs + 1) * 2;
end_off = hfs_bnode_read_u16(node, end_rec_off);
end_rec_off -= 2;
- dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
+ hfs_dbg(BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
rec, size, end_off, end_rec_off);
if (size > end_rec_off - end_off) {
if (new_node)
@@ -191,7 +191,7 @@ again:
mark_inode_dirty(tree->inode);
}
hfs_bnode_dump(node);
- dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n",
+ hfs_dbg(BNODE_MOD, "remove_rec: %d, %d\n",
fd->record, fd->keylength + fd->entrylength);
if (!--node->num_recs) {
hfs_bnode_unlink(node);
@@ -244,7 +244,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
if (IS_ERR(new_node))
return new_node;
hfs_bnode_get(node);
- dprint(DBG_BNODE_MOD, "split_nodes: %d - %d - %d\n",
+ hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n",
node->this, new_node->this, node->next);
new_node->next = node->next;
new_node->prev = node->this;
@@ -379,7 +379,7 @@ again:
newkeylen = hfs_bnode_read_u16(node, 14) + 2;
else
fd->keylength = newkeylen = tree->max_key_len + 2;
- dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n",
+ hfs_dbg(BNODE_MOD, "update_rec: %d, %d, %d\n",
rec, fd->keylength, newkeylen);

rec_off = tree->node_size - (rec + 2) * 2;
@@ -391,7 +391,7 @@ again:
end_off = hfs_bnode_read_u16(parent, end_rec_off);
if (end_rec_off - end_off < diff) {

- dprint(DBG_BNODE_MOD, "hfs: splitting index node.\n");
+ hfs_dbg(BNODE_MOD, "splitting index node\n");
fd->bnode = parent;
new_node = hfs_bnode_split(fd);
if (IS_ERR(new_node))
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index efb689c..c2fa4bf 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -303,7 +303,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
kunmap(*pagep);
nidx = node->next;
if (!nidx) {
- dprint(DBG_BNODE_MOD, "hfs: create new bmap node.\n");
+ hfs_dbg(BNODE_MOD, "create new bmap node\n");
next_node = hfs_bmap_new_bmap(node, idx);
} else
next_node = hfs_bnode_find(tree, nidx);
@@ -329,7 +329,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
u32 nidx;
u8 *data, byte, m;

- dprint(DBG_BNODE_MOD, "btree_free_node: %u\n", node->this);
+ hfs_dbg(BNODE_MOD, "btree_free_node: %u\n", node->this);
BUG_ON(!node->this);
tree = node->tree;
nidx = node->this;
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 840d71e..12cea23 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -212,7 +212,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
int entry_size;
int err;

- dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n",
+ hfs_dbg(CAT_MOD, "create_cat: %s,%u(%d)\n",
str->name, cnid, inode->i_nlink);
err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
if (err)
@@ -271,8 +271,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
int err, off;
u16 type;

- dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n",
- str ? str->name : NULL, cnid);
+ hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
if (err)
return err;
@@ -361,7 +360,7 @@ int hfsplus_rename_cat(u32 cnid,
int entry_size, type;
int err;

- dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
+ hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
cnid, src_dir->i_ino, src_name->name,
dst_dir->i_ino, dst_name->name);
err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &src_fd);
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index a94f0f7..7541731 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -265,7 +265,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
mutex_unlock(&hip->extents_lock);

done:
- dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n",
+ hfs_dbg(EXTENT, "get_block(%lu): %llu - %u\n",
inode->i_ino, (long long)iblock, dblock);

mask = (1 << sbi->fs_shift) - 1;
@@ -288,11 +288,12 @@ static void hfsplus_dump_extent(struct hfsplus_extent *extent)
{
int i;

- dprint(DBG_EXTENT, " ");
+ hfs_dbg(EXTENT, " ");
for (i = 0; i < 8; i++)
- dprint(DBG_EXTENT, " %u:%u", be32_to_cpu(extent[i].start_block),
- be32_to_cpu(extent[i].block_count));
- dprint(DBG_EXTENT, "\n");
+ hfs_dbg_cont(EXTENT, " %u:%u",
+ be32_to_cpu(extent[i].start_block),
+ be32_to_cpu(extent[i].block_count));
+ hfs_dbg_cont(EXTENT, "\n");
}

static int hfsplus_add_extent(struct hfsplus_extent *extent, u32 offset,
@@ -349,7 +350,7 @@ found:
err = hfsplus_block_free(sb, start, count);
if (err) {
printk(KERN_ERR "hfs: can't free extent\n");
- dprint(DBG_EXTENT, " start: %u count: %u\n",
+ hfs_dbg(EXTENT, " start: %u count: %u\n",
start, count);
}
extent->block_count = 0;
@@ -360,7 +361,7 @@ found:
err = hfsplus_block_free(sb, start + count, block_nr);
if (err) {
printk(KERN_ERR "hfs: can't free extent\n");
- dprint(DBG_EXTENT, " start: %u count: %u\n",
+ hfs_dbg(EXTENT, " start: %u count: %u\n",
start, count);
}
extent->block_count = cpu_to_be32(count);
@@ -459,11 +460,11 @@ int hfsplus_file_extend(struct inode *inode)
}
}

- dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
+ hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);

if (hip->alloc_blocks <= hip->first_blocks) {
if (!hip->first_blocks) {
- dprint(DBG_EXTENT, "first extents\n");
+ hfs_dbg(EXTENT, "first extents\n");
/* no extents yet */
hip->first_extents[0].start_block = cpu_to_be32(start);
hip->first_extents[0].block_count = cpu_to_be32(len);
@@ -500,7 +501,7 @@ out:
return res;

insert_extent:
- dprint(DBG_EXTENT, "insert new extent\n");
+ hfs_dbg(EXTENT, "insert new extent\n");
res = hfsplus_ext_write_extent_locked(inode);
if (res)
goto out;
@@ -525,9 +526,8 @@ void hfsplus_file_truncate(struct inode *inode)
u32 alloc_cnt, blk_cnt, start;
int res;

- dprint(DBG_INODE, "truncate: %lu, %llu -> %llu\n",
- inode->i_ino, (long long)hip->phys_size,
- inode->i_size);
+ hfs_dbg(INODE, "truncate: %lu, %llu -> %llu\n",
+ inode->i_ino, (long long)hip->phys_size, inode->i_size);

if (inode->i_size > hip->phys_size) {
struct address_space *mapping = inode->i_mapping;
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 05b11f3..910ea98e 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -32,9 +32,17 @@
#endif
#define DBG_MASK (0)

-#define dprint(flg, fmt, args...) \
- if (flg & DBG_MASK) \
- printk(fmt , ## args)
+#define hfs_dbg(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
+} while (0)
+
+#define hfs_dbg_cont(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_CONT fmt, ##__VA_ARGS__); \
+} while (0)

/* Runtime config options */
#define HFSPLUS_DEF_CR_TYPE 0x3F3F3F3F /* '????' */
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 7b87284..4886fd3 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -145,7 +145,7 @@ static int hfsplus_write_inode(struct inode *inode,
{
int err;

- dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
+ hfs_dbg(INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);

err = hfsplus_ext_write_extent(inode);
if (err)
@@ -160,7 +160,7 @@ static int hfsplus_write_inode(struct inode *inode,

static void hfsplus_evict_inode(struct inode *inode)
{
- dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
+ hfs_dbg(INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
truncate_inode_pages(&inode->i_data, 0);
clear_inode(inode);
if (HFSPLUS_IS_RSRC(inode)) {
@@ -179,7 +179,7 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait)
if (!wait)
return 0;

- dprint(DBG_SUPER, "hfsplus_sync_fs\n");
+ hfs_dbg(SUPER, "hfsplus_sync_fs\n");

/*
* Explicitly write out the special metadata inodes.
@@ -275,7 +275,7 @@ static void hfsplus_put_super(struct super_block *sb)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);

- dprint(DBG_SUPER, "hfsplus_put_super\n");
+ hfs_dbg(SUPER, "hfsplus_put_super\n");

cancel_delayed_work_sync(&sbi->sync_work);

--
1.8.1.2.459.gbcd45b4.dirty

2013-04-08 16:38:23

by Joe Perches

[permalink] [raw]
Subject: [PATCH 2/2] hfs/hfsplus: Convert printks to pr_<level>

Use a more current logging style.

Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
hfsplus now uses "hfsplus: " for all messages.
Coalesce formats.
Prefix debugging messages too.

Signed-off-by: Joe Perches <[email protected]>
---
fs/hfs/bfind.c | 4 ++--
fs/hfs/bnode.c | 4 ++--
fs/hfs/brec.c | 8 +++-----
fs/hfs/btree.c | 29 ++++++++++++++++-------------
fs/hfs/catalog.c | 4 ++--
fs/hfs/dir.c | 12 ++++++------
fs/hfs/hfs_fs.h | 22 ++++++++++++++--------
fs/hfs/mdb.c | 23 +++++++++++------------
fs/hfs/super.c | 43 +++++++++++++++++++++----------------------
fs/hfsplus/attributes.c | 18 +++++++++---------
fs/hfsplus/bfind.c | 2 +-
fs/hfsplus/bitmap.c | 2 +-
fs/hfsplus/bnode.c | 6 +++---
fs/hfsplus/brec.c | 4 ++--
fs/hfsplus/btree.c | 25 ++++++++++++-------------
fs/hfsplus/catalog.c | 4 ++--
fs/hfsplus/dir.c | 14 +++++++-------
fs/hfsplus/extents.c | 6 +++---
fs/hfsplus/hfsplus_fs.h | 22 ++++++++++++++--------
fs/hfsplus/inode.c | 4 ++--
fs/hfsplus/options.c | 22 +++++++++++-----------
fs/hfsplus/super.c | 48 ++++++++++++++++++------------------------------
fs/hfsplus/wrapper.c | 8 +++-----
fs/hfsplus/xattr.c | 41 ++++++++++++++++++++---------------------
24 files changed, 185 insertions(+), 190 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index e928f6c..de69d8a 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -137,8 +137,8 @@ int hfs_brec_find(struct hfs_find_data *fd)
return res;

invalid:
- printk(KERN_ERR "hfs: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
- height, bnode->height, bnode->type, nidx, parent);
+ pr_err("inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
+ height, bnode->height, bnode->type, nidx, parent);
res = -EIO;
release:
hfs_bnode_put(bnode);
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 8693919..f3b1a15 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -221,7 +221,7 @@ struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid)
struct hfs_bnode *node;

if (cnid >= tree->node_count) {
- printk(KERN_ERR "hfs: request for non-existent node %d in B*Tree\n", cnid);
+ pr_err("request for non-existent node %d in B*Tree\n", cnid);
return NULL;
}

@@ -244,7 +244,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
loff_t off;

if (cnid >= tree->node_count) {
- printk(KERN_ERR "hfs: request for non-existent node %d in B*Tree\n", cnid);
+ pr_err("request for non-existent node %d in B*Tree\n", cnid);
return NULL;
}

diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 5764257..9f4ee7f 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -47,15 +47,13 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
if (node->tree->attributes & HFS_TREE_BIGKEYS) {
retval = hfs_bnode_read_u16(node, recoff) + 2;
if (retval > node->tree->max_key_len + 2) {
- printk(KERN_ERR "hfs: keylen %d too large\n",
- retval);
+ pr_err("keylen %d too large\n", retval);
retval = 0;
}
} else {
retval = (hfs_bnode_read_u8(node, recoff) | 1) + 1;
if (retval > node->tree->max_key_len + 1) {
- printk(KERN_ERR "hfs: keylen %d too large\n",
- retval);
+ pr_err("keylen %d too large\n", retval);
retval = 0;
}
}
@@ -388,7 +386,7 @@ again:
end_off = hfs_bnode_read_u16(parent, end_rec_off);
if (end_rec_off - end_off < diff) {

- printk(KERN_DEBUG "hfs: splitting index node...\n");
+ printk(KERN_DEBUG "splitting index node...\n");
fd->bnode = parent;
new_node = hfs_bnode_split(fd);
if (IS_ERR(new_node))
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 07d94ce..1ab19e6 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -48,7 +48,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
mdb->drXTFlSize, be32_to_cpu(mdb->drXTClpSiz));
if (HFS_I(tree->inode)->alloc_blocks >
HFS_I(tree->inode)->first_blocks) {
- printk(KERN_ERR "hfs: invalid btree extent records\n");
+ pr_err("invalid btree extent records\n");
unlock_new_inode(tree->inode);
goto free_inode;
}
@@ -60,8 +60,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
mdb->drCTFlSize, be32_to_cpu(mdb->drCTClpSiz));

if (!HFS_I(tree->inode)->first_blocks) {
- printk(KERN_ERR "hfs: invalid btree extent records "
- "(0 size).\n");
+ pr_err("invalid btree extent records (0 size)\n");
unlock_new_inode(tree->inode);
goto free_inode;
}
@@ -100,15 +99,15 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
switch (id) {
case HFS_EXT_CNID:
if (tree->max_key_len != HFS_MAX_EXT_KEYLEN) {
- printk(KERN_ERR "hfs: invalid extent max_key_len %d\n",
- tree->max_key_len);
+ pr_err("invalid extent max_key_len %d\n",
+ tree->max_key_len);
goto fail_page;
}
break;
case HFS_CAT_CNID:
if (tree->max_key_len != HFS_MAX_CAT_KEYLEN) {
- printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n",
- tree->max_key_len);
+ pr_err("invalid catalog max_key_len %d\n",
+ tree->max_key_len);
goto fail_page;
}
break;
@@ -146,8 +145,9 @@ void hfs_btree_close(struct hfs_btree *tree)
while ((node = tree->node_hash[i])) {
tree->node_hash[i] = node->next_hash;
if (atomic_read(&node->refcnt))
- printk(KERN_ERR "hfs: node %d:%d still has %d user(s)!\n",
- node->tree->cnid, node->this, atomic_read(&node->refcnt));
+ pr_err("node %d:%d still has %d user(s)!\n",
+ node->tree->cnid, node->this,
+ atomic_read(&node->refcnt));
hfs_bnode_free(node);
tree->node_hash_cnt--;
}
@@ -290,7 +290,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
kunmap(*pagep);
nidx = node->next;
if (!nidx) {
- printk(KERN_DEBUG "hfs: create new bmap node...\n");
+ printk(KERN_DEBUG "create new bmap node...\n");
next_node = hfs_bmap_new_bmap(node, idx);
} else
next_node = hfs_bnode_find(tree, nidx);
@@ -331,7 +331,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
hfs_bnode_put(node);
if (!i) {
/* panic */;
- printk(KERN_CRIT "hfs: unable to free bnode %u. bmap not found!\n", node->this);
+ pr_crit("unable to free bnode %u. bmap not found!\n",
+ node->this);
return;
}
node = hfs_bnode_find(tree, i);
@@ -339,7 +340,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
return;
if (node->type != HFS_NODE_MAP) {
/* panic */;
- printk(KERN_CRIT "hfs: invalid bmap found! (%u,%d)\n", node->this, node->type);
+ pr_crit("invalid bmap found! (%u,%d)\n",
+ node->this, node->type);
hfs_bnode_put(node);
return;
}
@@ -352,7 +354,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
m = 1 << (~nidx & 7);
byte = data[off];
if (!(byte & m)) {
- printk(KERN_CRIT "hfs: trying to free free bnode %u(%d)\n", node->this, node->type);
+ pr_crit("trying to free free bnode %u(%d)\n",
+ node->this, node->type);
kunmap(page);
hfs_bnode_put(node);
return;
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 76cfb17..80732ab 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -185,14 +185,14 @@ int hfs_cat_find_brec(struct super_block *sb, u32 cnid,

type = rec.type;
if (type != HFS_CDR_THD && type != HFS_CDR_FTH) {
- printk(KERN_ERR "hfs: found bad thread record in catalog\n");
+ pr_err("found bad thread record in catalog\n");
return -EIO;
}

fd->search_key->cat.ParID = rec.thread.ParID;
len = fd->search_key->cat.CName.len = rec.thread.CName.len;
if (len > HFS_NAMELEN) {
- printk(KERN_ERR "hfs: bad catalog namelength\n");
+ pr_err("bad catalog namelength\n");
return -EIO;
}
memcpy(fd->search_key->cat.CName.name, rec.thread.CName.name, len);
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 5f7f1ab..dbeca24 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -84,12 +84,12 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)

hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
if (entry.type != HFS_CDR_THD) {
- printk(KERN_ERR "hfs: bad catalog folder thread\n");
+ pr_err("bad catalog folder thread\n");
err = -EIO;
goto out;
}
//if (fd.entrylength < HFS_MIN_THREAD_SZ) {
- // printk(KERN_ERR "hfs: truncated catalog thread\n");
+ // pr_err("truncated catalog thread\n");
// err = -EIO;
// goto out;
//}
@@ -108,7 +108,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)

for (;;) {
if (be32_to_cpu(fd.key->cat.ParID) != inode->i_ino) {
- printk(KERN_ERR "hfs: walked past end of dir\n");
+ pr_err("walked past end of dir\n");
err = -EIO;
goto out;
}
@@ -123,7 +123,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName);
if (type == HFS_CDR_DIR) {
if (fd.entrylength < sizeof(struct hfs_cat_dir)) {
- printk(KERN_ERR "hfs: small dir entry\n");
+ pr_err("small dir entry\n");
err = -EIO;
goto out;
}
@@ -132,7 +132,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
break;
} else if (type == HFS_CDR_FIL) {
if (fd.entrylength < sizeof(struct hfs_cat_file)) {
- printk(KERN_ERR "hfs: small file entry\n");
+ pr_err("small file entry\n");
err = -EIO;
goto out;
}
@@ -140,7 +140,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
be32_to_cpu(entry.file.FlNum), DT_REG))
break;
} else {
- printk(KERN_ERR "hfs: bad catalog entry type %d\n", type);
+ pr_err("bad catalog entry type %d\n", type);
err = -EIO;
goto out;
}
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index cf088e0..681fc45 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -9,6 +9,12 @@
#ifndef _LINUX_HFS_FS_H
#define _LINUX_HFS_FS_H

+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/mutex.h>
@@ -34,16 +40,16 @@
//#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
#define DBG_MASK (0)

-#define hfs_dbg(flg, fmt, ...) \
-do { \
- if (DBG_##flg & DBG_MASK) \
- printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
+#define hfs_dbg(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)

-#define hfs_dbg_cont(flg, fmt, ...) \
-do { \
- if (DBG_##flg & DBG_MASK) \
- printk(KERN_CONT fmt, ##__VA_ARGS__); \
+#define hfs_dbg_cont(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ pr_cont(fmt, ##__VA_ARGS__); \
} while (0)


diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index b7ec224..aa3f0d6 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -48,7 +48,7 @@ static int hfs_get_last_session(struct super_block *sb,
*start = (sector_t)te.cdte_addr.lba << 2;
return 0;
}
- printk(KERN_ERR "hfs: invalid session number or type of track\n");
+ pr_err("invalid session number or type of track\n");
return -EINVAL;
}
ms_info.addr_format = CDROM_LBA;
@@ -101,7 +101,7 @@ int hfs_mdb_get(struct super_block *sb)

HFS_SB(sb)->alloc_blksz = size = be32_to_cpu(mdb->drAlBlkSiz);
if (!size || (size & (HFS_SECTOR_SIZE - 1))) {
- printk(KERN_ERR "hfs: bad allocation block size %d\n", size);
+ pr_err("bad allocation block size %d\n", size);
goto out_bh;
}

@@ -118,7 +118,7 @@ int hfs_mdb_get(struct super_block *sb)
size >>= 1;
brelse(bh);
if (!sb_set_blocksize(sb, size)) {
- printk(KERN_ERR "hfs: unable to set blocksize to %u\n", size);
+ pr_err("unable to set blocksize to %u\n", size);
goto out;
}

@@ -162,8 +162,8 @@ int hfs_mdb_get(struct super_block *sb)
}

if (!HFS_SB(sb)->alt_mdb) {
- printk(KERN_WARNING "hfs: unable to locate alternate MDB\n");
- printk(KERN_WARNING "hfs: continuing without an alternate MDB\n");
+ pr_warn("unable to locate alternate MDB\n");
+ pr_warn("continuing without an alternate MDB\n");
}

HFS_SB(sb)->bitmap = (__be32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0);
@@ -178,7 +178,7 @@ int hfs_mdb_get(struct super_block *sb)
while (size) {
bh = sb_bread(sb, off >> sb->s_blocksize_bits);
if (!bh) {
- printk(KERN_ERR "hfs: unable to read volume bitmap\n");
+ pr_err("unable to read volume bitmap\n");
goto out;
}
off2 = off & (sb->s_blocksize - 1);
@@ -192,23 +192,22 @@ int hfs_mdb_get(struct super_block *sb)

HFS_SB(sb)->ext_tree = hfs_btree_open(sb, HFS_EXT_CNID, hfs_ext_keycmp);
if (!HFS_SB(sb)->ext_tree) {
- printk(KERN_ERR "hfs: unable to open extent tree\n");
+ pr_err("unable to open extent tree\n");
goto out;
}
HFS_SB(sb)->cat_tree = hfs_btree_open(sb, HFS_CAT_CNID, hfs_cat_keycmp);
if (!HFS_SB(sb)->cat_tree) {
- printk(KERN_ERR "hfs: unable to open catalog tree\n");
+ pr_err("unable to open catalog tree\n");
goto out;
}

attrib = mdb->drAtrb;
if (!(attrib & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
- printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
- "running fsck.hfs is recommended. mounting read-only.\n");
+ pr_warn("filesystem was not cleanly unmounted, running fsck.hfs is recommended. mounting read-only.\n");
sb->s_flags |= MS_RDONLY;
}
if ((attrib & cpu_to_be16(HFS_SB_ATTRIB_SLOCK))) {
- printk(KERN_WARNING "hfs: filesystem is marked locked, mounting read-only.\n");
+ pr_warn("filesystem is marked locked, mounting read-only.\n");
sb->s_flags |= MS_RDONLY;
}
if (!(sb->s_flags & MS_RDONLY)) {
@@ -312,7 +311,7 @@ void hfs_mdb_commit(struct super_block *sb)
while (size) {
bh = sb_bread(sb, block);
if (!bh) {
- printk(KERN_ERR "hfs: unable to read volume bitmap\n");
+ pr_err("unable to read volume bitmap\n");
break;
}
len = min((int)sb->s_blocksize - off, size);
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index bbaaa8a..3420756 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -117,12 +117,11 @@ static int hfs_remount(struct super_block *sb, int *flags, char *data)
return 0;
if (!(*flags & MS_RDONLY)) {
if (!(HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
- printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
- "running fsck.hfs is recommended. leaving read-only.\n");
+ pr_warn("filesystem was not cleanly unmounted, running fsck.hfs is recommended. leaving read-only.\n");
sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY;
} else if (HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_SLOCK)) {
- printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
+ pr_warn("filesystem is marked locked, leaving read-only.\n");
sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY;
}
@@ -253,29 +252,29 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
switch (token) {
case opt_uid:
if (match_int(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: uid requires an argument\n");
+ pr_err("uid requires an argument\n");
return 0;
}
hsb->s_uid = make_kuid(current_user_ns(), (uid_t)tmp);
if (!uid_valid(hsb->s_uid)) {
- printk(KERN_ERR "hfs: invalid uid %d\n", tmp);
+ pr_err("invalid uid %d\n", tmp);
return 0;
}
break;
case opt_gid:
if (match_int(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: gid requires an argument\n");
+ pr_err("gid requires an argument\n");
return 0;
}
hsb->s_gid = make_kgid(current_user_ns(), (gid_t)tmp);
if (!gid_valid(hsb->s_gid)) {
- printk(KERN_ERR "hfs: invalid gid %d\n", tmp);
+ pr_err("invalid gid %d\n", tmp);
return 0;
}
break;
case opt_umask:
if (match_octal(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: umask requires a value\n");
+ pr_err("umask requires a value\n");
return 0;
}
hsb->s_file_umask = (umode_t)tmp;
@@ -283,39 +282,39 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
break;
case opt_file_umask:
if (match_octal(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: file_umask requires a value\n");
+ pr_err("file_umask requires a value\n");
return 0;
}
hsb->s_file_umask = (umode_t)tmp;
break;
case opt_dir_umask:
if (match_octal(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: dir_umask requires a value\n");
+ pr_err("dir_umask requires a value\n");
return 0;
}
hsb->s_dir_umask = (umode_t)tmp;
break;
case opt_part:
if (match_int(&args[0], &hsb->part)) {
- printk(KERN_ERR "hfs: part requires an argument\n");
+ pr_err("part requires an argument\n");
return 0;
}
break;
case opt_session:
if (match_int(&args[0], &hsb->session)) {
- printk(KERN_ERR "hfs: session requires an argument\n");
+ pr_err("session requires an argument\n");
return 0;
}
break;
case opt_type:
if (match_fourchar(&args[0], &hsb->s_type)) {
- printk(KERN_ERR "hfs: type requires a 4 character value\n");
+ pr_err("type requires a 4 character value\n");
return 0;
}
break;
case opt_creator:
if (match_fourchar(&args[0], &hsb->s_creator)) {
- printk(KERN_ERR "hfs: creator requires a 4 character value\n");
+ pr_err("creator requires a 4 character value\n");
return 0;
}
break;
@@ -324,14 +323,14 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
break;
case opt_codepage:
if (hsb->nls_disk) {
- printk(KERN_ERR "hfs: unable to change codepage\n");
+ pr_err("unable to change codepage\n");
return 0;
}
p = match_strdup(&args[0]);
if (p)
hsb->nls_disk = load_nls(p);
if (!hsb->nls_disk) {
- printk(KERN_ERR "hfs: unable to load codepage \"%s\"\n", p);
+ pr_err("unable to load codepage \"%s\"\n", p);
kfree(p);
return 0;
}
@@ -339,14 +338,14 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
break;
case opt_iocharset:
if (hsb->nls_io) {
- printk(KERN_ERR "hfs: unable to change iocharset\n");
+ pr_err("unable to change iocharset\n");
return 0;
}
p = match_strdup(&args[0]);
if (p)
hsb->nls_io = load_nls(p);
if (!hsb->nls_io) {
- printk(KERN_ERR "hfs: unable to load iocharset \"%s\"\n", p);
+ pr_err("unable to load iocharset \"%s\"\n", p);
kfree(p);
return 0;
}
@@ -360,7 +359,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
if (hsb->nls_disk && !hsb->nls_io) {
hsb->nls_io = load_nls_default();
if (!hsb->nls_io) {
- printk(KERN_ERR "hfs: unable to load default iocharset\n");
+ pr_err("unable to load default iocharset\n");
return 0;
}
}
@@ -400,7 +399,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)

res = -EINVAL;
if (!parse_options((char *)data, sbi)) {
- printk(KERN_ERR "hfs: unable to parse mount options.\n");
+ pr_err("unable to parse mount options\n");
goto bail;
}

@@ -411,7 +410,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
res = hfs_mdb_get(sb);
if (res) {
if (!silent)
- printk(KERN_WARNING "hfs: can't find a HFS filesystem on dev %s.\n",
+ pr_warn("can't find a HFS filesystem on dev %s\n",
hfs_mdb_name(sb));
res = -EINVAL;
goto bail;
@@ -447,7 +446,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
return 0;

bail_no_root:
- printk(KERN_ERR "hfs: get root inode failed.\n");
+ pr_err("get root inode failed\n");
bail:
hfs_mdb_put(sb);
return res;
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index 2043b50..0f47890 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -56,7 +56,7 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key,
if (name) {
len = strlen(name);
if (len > HFSPLUS_ATTR_MAX_STRLEN) {
- printk(KERN_ERR "hfs: invalid xattr name's length\n");
+ pr_err("invalid xattr name's length\n");
return -EINVAL;
}
hfsplus_asc2uni(sb,
@@ -169,7 +169,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
hfs_dbg(ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);

if (!HFSPLUS_SB(sb)->attr_tree) {
- printk(KERN_ERR "hfs: attributes file doesn't exist\n");
+ pr_err("attributes file doesn't exist\n");
return -EINVAL;
}

@@ -232,7 +232,7 @@ int hfsplus_create_attr(struct inode *inode,
name ? name : NULL, inode->i_ino);

if (!HFSPLUS_SB(sb)->attr_tree) {
- printk(KERN_ERR "hfs: attributes file doesn't exist\n");
+ pr_err("attributes file doesn't exist\n");
return -EINVAL;
}

@@ -307,10 +307,10 @@ static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
break;
case HFSPLUS_ATTR_FORK_DATA:
case HFSPLUS_ATTR_EXTENTS:
- printk(KERN_ERR "hfs: only inline data xattr are supported\n");
+ pr_err("only inline data xattr are supported\n");
return -EOPNOTSUPP;
default:
- printk(KERN_ERR "hfs: invalid extended attribute record\n");
+ pr_err("invalid extended attribute record\n");
return -ENOENT;
}

@@ -332,7 +332,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
name ? name : NULL, inode->i_ino);

if (!HFSPLUS_SB(sb)->attr_tree) {
- printk(KERN_ERR "hfs: attributes file doesn't exist\n");
+ pr_err("attributes file doesn't exist\n");
return -EINVAL;
}

@@ -346,7 +346,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
if (err)
goto out;
} else {
- printk(KERN_ERR "hfs: invalid extended attribute name\n");
+ pr_err("invalid extended attribute name\n");
err = -EINVAL;
goto out;
}
@@ -372,7 +372,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);

if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
- printk(KERN_ERR "hfs: attributes file doesn't exist\n");
+ pr_err("attributes file doesn't exist\n");
return -EINVAL;
}

@@ -384,7 +384,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
err = hfsplus_find_attr(dir->i_sb, cnid, NULL, &fd);
if (err) {
if (err != -ENOENT)
- printk(KERN_ERR "hfs: xattr search failed.\n");
+ pr_err("xattr search failed\n");
goto end_delete_all;
}

diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index d27f37f..c1422d9 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -208,7 +208,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
return res;

invalid:
- printk(KERN_ERR "hfs: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
+ pr_err("inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
height, bnode->height, bnode->type, nidx, parent);
res = -EIO;
release:
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index 7da6d46..826e864 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -238,7 +238,7 @@ out:
return 0;

kaboom:
- printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n",
+ pr_crit("hfsplus: unable to mark blocks free: error %ld\n",
PTR_ERR(page));
mutex_unlock(&sbi->alloc_mutex);

diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 1ca9304..11c8602 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -386,7 +386,7 @@ struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid)
struct hfs_bnode *node;

if (cnid >= tree->node_count) {
- printk(KERN_ERR "hfs: request for non-existent node "
+ pr_err("request for non-existent node "
"%d in B*Tree\n",
cnid);
return NULL;
@@ -409,7 +409,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
loff_t off;

if (cnid >= tree->node_count) {
- printk(KERN_ERR "hfs: request for non-existent node "
+ pr_err("request for non-existent node "
"%d in B*Tree\n",
cnid);
return NULL;
@@ -588,7 +588,7 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num)
node = hfs_bnode_findhash(tree, num);
spin_unlock(&tree->hash_lock);
if (node) {
- printk(KERN_CRIT "new node %u already hashed?\n", num);
+ pr_crit("new node %u already hashed?\n", num);
WARN_ON(1);
return node;
}
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index e238ba8..6e560d5 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -45,13 +45,13 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
if (!recoff)
return 0;
if (recoff > node->tree->node_size - 2) {
- printk(KERN_ERR "hfs: recoff %d too large\n", recoff);
+ pr_err("recoff %d too large\n", recoff);
return 0;
}

retval = hfs_bnode_read_u16(node, recoff) + 2;
if (retval > node->tree->max_key_len + 2) {
- printk(KERN_ERR "hfs: keylen %d too large\n",
+ pr_err("keylen %d too large\n",
retval);
retval = 0;
}
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index c2fa4bf..0c6540c 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -40,8 +40,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
tree->inode = inode;

if (!HFSPLUS_I(tree->inode)->first_blocks) {
- printk(KERN_ERR
- "hfs: invalid btree extent records (0 size).\n");
+ pr_err("invalid btree extent records (0 size)\n");
goto free_inode;
}

@@ -68,12 +67,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
switch (id) {
case HFSPLUS_EXT_CNID:
if (tree->max_key_len != HFSPLUS_EXT_KEYLEN - sizeof(u16)) {
- printk(KERN_ERR "hfs: invalid extent max_key_len %d\n",
+ pr_err("invalid extent max_key_len %d\n",
tree->max_key_len);
goto fail_page;
}
if (tree->attributes & HFS_TREE_VARIDXKEYS) {
- printk(KERN_ERR "hfs: invalid extent btree flag\n");
+ pr_err("invalid extent btree flag\n");
goto fail_page;
}

@@ -81,12 +80,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
break;
case HFSPLUS_CAT_CNID:
if (tree->max_key_len != HFSPLUS_CAT_KEYLEN - sizeof(u16)) {
- printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n",
+ pr_err("invalid catalog max_key_len %d\n",
tree->max_key_len);
goto fail_page;
}
if (!(tree->attributes & HFS_TREE_VARIDXKEYS)) {
- printk(KERN_ERR "hfs: invalid catalog btree flag\n");
+ pr_err("invalid catalog btree flag\n");
goto fail_page;
}

@@ -100,19 +99,19 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
break;
case HFSPLUS_ATTR_CNID:
if (tree->max_key_len != HFSPLUS_ATTR_KEYLEN - sizeof(u16)) {
- printk(KERN_ERR "hfs: invalid attributes max_key_len %d\n",
+ pr_err("invalid attributes max_key_len %d\n",
tree->max_key_len);
goto fail_page;
}
tree->keycmp = hfsplus_attr_bin_cmp_key;
break;
default:
- printk(KERN_ERR "hfs: unknown B*Tree requested\n");
+ pr_err("unknown B*Tree requested\n");
goto fail_page;
}

if (!(tree->attributes & HFS_TREE_BIGKEYS)) {
- printk(KERN_ERR "hfs: invalid btree flag\n");
+ pr_err("invalid btree flag\n");
goto fail_page;
}

@@ -155,7 +154,7 @@ void hfs_btree_close(struct hfs_btree *tree)
while ((node = tree->node_hash[i])) {
tree->node_hash[i] = node->next_hash;
if (atomic_read(&node->refcnt))
- printk(KERN_CRIT "hfs: node %d:%d "
+ pr_crit("node %d:%d "
"still has %d user(s)!\n",
node->tree->cnid, node->this,
atomic_read(&node->refcnt));
@@ -345,7 +344,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
hfs_bnode_put(node);
if (!i) {
/* panic */;
- printk(KERN_CRIT "hfs: unable to free bnode %u. "
+ pr_crit("unable to free bnode %u. "
"bmap not found!\n",
node->this);
return;
@@ -355,7 +354,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
return;
if (node->type != HFS_NODE_MAP) {
/* panic */;
- printk(KERN_CRIT "hfs: invalid bmap found! "
+ pr_crit("invalid bmap found! "
"(%u,%d)\n",
node->this, node->type);
hfs_bnode_put(node);
@@ -370,7 +369,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
m = 1 << (~nidx & 7);
byte = data[off];
if (!(byte & m)) {
- printk(KERN_CRIT "hfs: trying to free free bnode "
+ pr_crit("trying to free free bnode "
"%u(%d)\n",
node->this, node->type);
kunmap(page);
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 12cea23..968ce41 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -188,12 +188,12 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,

type = be16_to_cpu(tmp.type);
if (type != HFSPLUS_FOLDER_THREAD && type != HFSPLUS_FILE_THREAD) {
- printk(KERN_ERR "hfs: found bad thread record in catalog\n");
+ pr_err("found bad thread record in catalog\n");
return -EIO;
}

if (be16_to_cpu(tmp.thread.nodeName.length) > 255) {
- printk(KERN_ERR "hfs: catalog name length corrupted\n");
+ pr_err("catalog name length corrupted\n");
return -EIO;
}

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 031c24e..a37ac93 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -103,7 +103,7 @@ again:
} else if (!dentry->d_fsdata)
dentry->d_fsdata = (void *)(unsigned long)cnid;
} else {
- printk(KERN_ERR "hfs: invalid catalog entry type in lookup\n");
+ pr_err("invalid catalog entry type in lookup\n");
err = -EIO;
goto fail;
}
@@ -159,12 +159,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
fd.entrylength);
if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
- printk(KERN_ERR "hfs: bad catalog folder thread\n");
+ pr_err("bad catalog folder thread\n");
err = -EIO;
goto out;
}
if (fd.entrylength < HFSPLUS_MIN_THREAD_SZ) {
- printk(KERN_ERR "hfs: truncated catalog thread\n");
+ pr_err("truncated catalog thread\n");
err = -EIO;
goto out;
}
@@ -183,7 +183,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)

for (;;) {
if (be32_to_cpu(fd.key->cat.parent) != inode->i_ino) {
- printk(KERN_ERR "hfs: walked past end of dir\n");
+ pr_err("walked past end of dir\n");
err = -EIO;
goto out;
}
@@ -203,7 +203,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (type == HFSPLUS_FOLDER) {
if (fd.entrylength <
sizeof(struct hfsplus_cat_folder)) {
- printk(KERN_ERR "hfs: small dir entry\n");
+ pr_err("small dir entry\n");
err = -EIO;
goto out;
}
@@ -216,7 +216,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
break;
} else if (type == HFSPLUS_FILE) {
if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
- printk(KERN_ERR "hfs: small file entry\n");
+ pr_err("small file entry\n");
err = -EIO;
goto out;
}
@@ -224,7 +224,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
be32_to_cpu(entry.file.id), DT_REG))
break;
} else {
- printk(KERN_ERR "hfs: bad catalog entry type\n");
+ pr_err("bad catalog entry type\n");
err = -EIO;
goto out;
}
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 7541731..e38f1fa 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -349,7 +349,7 @@ found:
if (count <= block_nr) {
err = hfsplus_block_free(sb, start, count);
if (err) {
- printk(KERN_ERR "hfs: can't free extent\n");
+ pr_err("can't free extent\n");
hfs_dbg(EXTENT, " start: %u count: %u\n",
start, count);
}
@@ -360,7 +360,7 @@ found:
count -= block_nr;
err = hfsplus_block_free(sb, start + count, block_nr);
if (err) {
- printk(KERN_ERR "hfs: can't free extent\n");
+ pr_err("can't free extent\n");
hfs_dbg(EXTENT, " start: %u count: %u\n",
start, count);
}
@@ -433,7 +433,7 @@ int hfsplus_file_extend(struct inode *inode)
if (sbi->alloc_file->i_size * 8 <
sbi->total_blocks - sbi->free_blocks + 8) {
/* extend alloc file */
- printk(KERN_ERR "hfs: extend alloc file! "
+ pr_err("extend alloc file! "
"(%llu,%u,%u)\n",
sbi->alloc_file->i_size * 8,
sbi->total_blocks, sbi->free_blocks);
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 910ea98e..60b0a33 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -10,6 +10,12 @@
#ifndef _LINUX_HFSPLUS_FS_H
#define _LINUX_HFSPLUS_FS_H

+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/fs.h>
#include <linux/mutex.h>
#include <linux/buffer_head.h>
@@ -32,16 +38,16 @@
#endif
#define DBG_MASK (0)

-#define hfs_dbg(flg, fmt, ...) \
-do { \
- if (DBG_##flg & DBG_MASK) \
- printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
+#define hfs_dbg(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)

-#define hfs_dbg_cont(flg, fmt, ...) \
-do { \
- if (DBG_##flg & DBG_MASK) \
- printk(KERN_CONT fmt, ##__VA_ARGS__); \
+#define hfs_dbg_cont(flg, fmt, ...) \
+do { \
+ if (DBG_##flg & DBG_MASK) \
+ pr_cont(fmt, ##__VA_ARGS__); \
} while (0)

/* Runtime config options */
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index cdd181d..f833d35 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -358,7 +358,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
if (!error)
error = error2;
} else {
- printk(KERN_ERR "hfs: sync non-existent attributes tree\n");
+ pr_err("sync non-existent attributes tree\n");
}
}

@@ -574,7 +574,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
HFSPLUS_I(inode)->create_date = file->create_date;
} else {
- printk(KERN_ERR "hfs: bad catalog entry used to create inode\n");
+ pr_err("bad catalog entry used to create inode\n");
res = -EIO;
}
return res;
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index ed257c6..968eab5 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -113,67 +113,67 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
switch (token) {
case opt_creator:
if (match_fourchar(&args[0], &sbi->creator)) {
- printk(KERN_ERR "hfs: creator requires a 4 character value\n");
+ pr_err("creator requires a 4 character value\n");
return 0;
}
break;
case opt_type:
if (match_fourchar(&args[0], &sbi->type)) {
- printk(KERN_ERR "hfs: type requires a 4 character value\n");
+ pr_err("type requires a 4 character value\n");
return 0;
}
break;
case opt_umask:
if (match_octal(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: umask requires a value\n");
+ pr_err("umask requires a value\n");
return 0;
}
sbi->umask = (umode_t)tmp;
break;
case opt_uid:
if (match_int(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: uid requires an argument\n");
+ pr_err("uid requires an argument\n");
return 0;
}
sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
if (!uid_valid(sbi->uid)) {
- printk(KERN_ERR "hfs: invalid uid specified\n");
+ pr_err("invalid uid specified\n");
return 0;
}
break;
case opt_gid:
if (match_int(&args[0], &tmp)) {
- printk(KERN_ERR "hfs: gid requires an argument\n");
+ pr_err("gid requires an argument\n");
return 0;
}
sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
if (!gid_valid(sbi->gid)) {
- printk(KERN_ERR "hfs: invalid gid specified\n");
+ pr_err("invalid gid specified\n");
return 0;
}
break;
case opt_part:
if (match_int(&args[0], &sbi->part)) {
- printk(KERN_ERR "hfs: part requires an argument\n");
+ pr_err("part requires an argument\n");
return 0;
}
break;
case opt_session:
if (match_int(&args[0], &sbi->session)) {
- printk(KERN_ERR "hfs: session requires an argument\n");
+ pr_err("session requires an argument\n");
return 0;
}
break;
case opt_nls:
if (sbi->nls) {
- printk(KERN_ERR "hfs: unable to change nls mapping\n");
+ pr_err("unable to change nls mapping\n");
return 0;
}
p = match_strdup(&args[0]);
if (p)
sbi->nls = load_nls(p);
if (!sbi->nls) {
- printk(KERN_ERR "hfs: unable to load "
+ pr_err("unable to load "
"nls mapping \"%s\"\n",
p);
kfree(p);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 4886fd3..4c4d142 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -132,7 +132,7 @@ static int hfsplus_system_write_inode(struct inode *inode)
if (tree) {
int err = hfs_btree_write(tree);
if (err) {
- printk(KERN_ERR "hfs: b-tree write err: %d, ino %lu\n",
+ pr_err("b-tree write err: %d, ino %lu\n",
err, inode->i_ino);
return err;
}
@@ -251,7 +251,7 @@ static void delayed_sync_fs(struct work_struct *work)

err = hfsplus_sync_fs(sbi->alloc_file->i_sb, 1);
if (err)
- printk(KERN_ERR "hfs: delayed sync fs err %d\n", err);
+ pr_err("delayed sync fs err %d\n", err);
}

void hfsplus_mark_mdb_dirty(struct super_block *sb)
@@ -333,25 +333,19 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
return -EINVAL;

if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
- printk(KERN_WARNING "hfs: filesystem was "
- "not cleanly unmounted, "
- "running fsck.hfsplus is recommended. "
- "leaving read-only.\n");
+ pr_warn("filesystem was not cleanly unmounted, running fsck.hfsplus is recommended. leaving read-only.\n");
sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY;
} else if (force) {
/* nothing */
} else if (vhdr->attributes &
cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
- printk(KERN_WARNING "hfs: filesystem is marked locked, "
- "leaving read-only.\n");
+ pr_warn("filesystem is marked locked, leaving read-only.\n");
sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY;
} else if (vhdr->attributes &
cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
- printk(KERN_WARNING "hfs: filesystem is "
- "marked journaled, "
- "leaving read-only.\n");
+ pr_warn("filesystem is marked journaled, leaving read-only.\n");
sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY;
}
@@ -397,7 +391,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)

err = -EINVAL;
if (!hfsplus_parse_options(data, sbi)) {
- printk(KERN_ERR "hfs: unable to parse mount options\n");
+ pr_err("unable to parse mount options\n");
goto out_unload_nls;
}

@@ -405,14 +399,14 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
nls = sbi->nls;
sbi->nls = load_nls("utf8");
if (!sbi->nls) {
- printk(KERN_ERR "hfs: unable to load nls for utf8\n");
+ pr_err("unable to load nls for utf8\n");
goto out_unload_nls;
}

/* Grab the volume header */
if (hfsplus_read_wrapper(sb)) {
if (!silent)
- printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n");
+ pr_warn("unable to find HFS+ superblock\n");
goto out_unload_nls;
}
vhdr = sbi->s_vhdr;
@@ -421,7 +415,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
sb->s_magic = HFSPLUS_VOLHEAD_SIG;
if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION ||
be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) {
- printk(KERN_ERR "hfs: wrong filesystem version\n");
+ pr_err("wrong filesystem version\n");
goto out_free_vhdr;
}
sbi->total_blocks = be32_to_cpu(vhdr->total_blocks);
@@ -445,7 +439,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)

if ((last_fs_block > (sector_t)(~0ULL) >> (sbi->alloc_blksz_shift - 9)) ||
(last_fs_page > (pgoff_t)(~0ULL))) {
- printk(KERN_ERR "hfs: filesystem size too large.\n");
+ pr_err("filesystem size too large\n");
goto out_free_vhdr;
}

@@ -454,22 +448,16 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
sb->s_maxbytes = MAX_LFS_FILESIZE;

if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
- printk(KERN_WARNING "hfs: Filesystem was "
- "not cleanly unmounted, "
- "running fsck.hfsplus is recommended. "
- "mounting read-only.\n");
+ pr_warn("Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended. mounting read-only.\n");
sb->s_flags |= MS_RDONLY;
} else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) {
/* nothing */
} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
- printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
+ pr_warn("Filesystem is marked locked, mounting read-only.\n");
sb->s_flags |= MS_RDONLY;
} else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) &&
!(sb->s_flags & MS_RDONLY)) {
- printk(KERN_WARNING "hfs: write access to "
- "a journaled filesystem is not supported, "
- "use the force option at your own risk, "
- "mounting read-only.\n");
+ pr_warn("write access to a journaled filesystem is not supported, use the force option at your own risk, mounting read-only.\n");
sb->s_flags |= MS_RDONLY;
}

@@ -478,18 +466,18 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
/* Load metadata objects (B*Trees) */
sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
if (!sbi->ext_tree) {
- printk(KERN_ERR "hfs: failed to load extents file\n");
+ pr_err("failed to load extents file\n");
goto out_free_vhdr;
}
sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
if (!sbi->cat_tree) {
- printk(KERN_ERR "hfs: failed to load catalog file\n");
+ pr_err("failed to load catalog file\n");
goto out_close_ext_tree;
}
if (vhdr->attr_file.total_blocks != 0) {
sbi->attr_tree = hfs_btree_open(sb, HFSPLUS_ATTR_CNID);
if (!sbi->attr_tree) {
- printk(KERN_ERR "hfs: failed to load attributes file\n");
+ pr_err("failed to load attributes file\n");
goto out_close_cat_tree;
}
}
@@ -497,7 +485,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)

inode = hfsplus_iget(sb, HFSPLUS_ALLOC_CNID);
if (IS_ERR(inode)) {
- printk(KERN_ERR "hfs: failed to load allocation file\n");
+ pr_err("failed to load allocation file\n");
err = PTR_ERR(inode);
goto out_close_attr_tree;
}
@@ -506,7 +494,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
/* Load the root directory */
root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID);
if (IS_ERR(root)) {
- printk(KERN_ERR "hfs: failed to load root directory\n");
+ pr_err("failed to load root directory\n");
err = PTR_ERR(root);
goto out_put_alloc_file;
}
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 2e7ffba..96375a5 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -157,7 +157,7 @@ static int hfsplus_get_last_session(struct super_block *sb,
*start = (sector_t)te.cdte_addr.lba << 2;
return 0;
}
- printk(KERN_ERR "hfs: invalid session number or type of track\n");
+ pr_err("invalid session number or type of track\n");
return -EINVAL;
}
ms_info.addr_format = CDROM_LBA;
@@ -235,8 +235,7 @@ reread:

error = -EINVAL;
if (sbi->s_backup_vhdr->signature != sbi->s_vhdr->signature) {
- printk(KERN_WARNING
- "hfs: invalid secondary volume header\n");
+ pr_warn("invalid secondary volume header\n");
goto out_free_backup_vhdr;
}

@@ -260,8 +259,7 @@ reread:
blocksize >>= 1;

if (sb_set_blocksize(sb, blocksize) != blocksize) {
- printk(KERN_ERR "hfs: unable to set blocksize to %u!\n",
- blocksize);
+ pr_err("unable to set blocksize to %u!\n", blocksize);
goto out_free_backup_vhdr;
}

diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index e8a4b08..f663461 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -107,19 +107,19 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,

err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
if (err) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
return err;
}

err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
if (err) {
- printk(KERN_ERR "hfs: catalog searching failed\n");
+ pr_err("catalog searching failed\n");
goto end_setxattr;
}

if (!strcmp_xattr_finder_info(name)) {
if (flags & XATTR_CREATE) {
- printk(KERN_ERR "hfs: xattr exists yet\n");
+ pr_err("xattr exists yet\n");
err = -EOPNOTSUPP;
goto end_setxattr;
}
@@ -165,7 +165,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,

if (hfsplus_attr_exists(inode, name)) {
if (flags & XATTR_CREATE) {
- printk(KERN_ERR "hfs: xattr exists yet\n");
+ pr_err("xattr exists yet\n");
err = -EOPNOTSUPP;
goto end_setxattr;
}
@@ -177,7 +177,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
goto end_setxattr;
} else {
if (flags & XATTR_REPLACE) {
- printk(KERN_ERR "hfs: cannot replace xattr\n");
+ pr_err("cannot replace xattr\n");
err = -EOPNOTSUPP;
goto end_setxattr;
}
@@ -210,7 +210,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
cat_entry_flags);
hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
} else {
- printk(KERN_ERR "hfs: invalid catalog entry type\n");
+ pr_err("invalid catalog entry type\n");
err = -EIO;
goto end_setxattr;
}
@@ -269,7 +269,7 @@ static ssize_t hfsplus_getxattr_finder_info(struct dentry *dentry,
if (size >= record_len) {
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
if (res) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
return res;
}
res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
@@ -340,13 +340,13 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,

entry = hfsplus_alloc_attr_entry();
if (!entry) {
- printk(KERN_ERR "hfs: can't allocate xattr entry\n");
+ pr_err("can't allocate xattr entry\n");
return -ENOMEM;
}

res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
if (res) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
goto failed_getxattr_init;
}

@@ -355,7 +355,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
if (res == -ENOENT)
res = -ENODATA;
else
- printk(KERN_ERR "hfs: xattr searching failed\n");
+ pr_err("xattr searching failed\n");
goto out;
}

@@ -368,17 +368,17 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
offsetof(struct hfsplus_attr_inline_data,
length));
if (record_length > HFSPLUS_MAX_INLINE_DATA_SIZE) {
- printk(KERN_ERR "hfs: invalid xattr record size\n");
+ pr_err("invalid xattr record size\n");
res = -EIO;
goto out;
}
} else if (record_type == HFSPLUS_ATTR_FORK_DATA ||
record_type == HFSPLUS_ATTR_EXTENTS) {
- printk(KERN_ERR "hfs: only inline data xattr are supported\n");
+ pr_err("only inline data xattr are supported\n");
res = -EOPNOTSUPP;
goto out;
} else {
- printk(KERN_ERR "hfs: invalid xattr record\n");
+ pr_err("invalid xattr record\n");
res = -EIO;
goto out;
}
@@ -427,7 +427,7 @@ static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry,

res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
if (res) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
return res;
}

@@ -506,7 +506,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)

err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
if (err) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
return err;
}

@@ -525,8 +525,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
for (;;) {
key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset);
if (key_len == 0 || key_len > fd.tree->max_key_len) {
- printk(KERN_ERR "hfs: invalid xattr key length: %d\n",
- key_len);
+ pr_err("invalid xattr key length: %d\n", key_len);
res = -EIO;
goto end_listxattr;
}
@@ -541,7 +540,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
if (hfsplus_uni2asc(inode->i_sb,
(const struct hfsplus_unistr *)&fd.key->attr.key_name,
strbuf, &xattr_name_len)) {
- printk(KERN_ERR "hfs: unicode conversion failed\n");
+ pr_err("unicode conversion failed\n");
res = -EIO;
goto end_listxattr;
}
@@ -598,13 +597,13 @@ int hfsplus_removexattr(struct dentry *dentry, const char *name)

err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
if (err) {
- printk(KERN_ERR "hfs: can't init xattr find struct\n");
+ pr_err("can't init xattr find struct\n");
return err;
}

err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
if (err) {
- printk(KERN_ERR "hfs: catalog searching failed\n");
+ pr_err("catalog searching failed\n");
goto end_removexattr;
}

@@ -643,7 +642,7 @@ int hfsplus_removexattr(struct dentry *dentry, const char *name)
flags);
hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
} else {
- printk(KERN_ERR "hfs: invalid catalog entry type\n");
+ pr_err("invalid catalog entry type\n");
err = -EIO;
goto end_removexattr;
}
--
1.8.1.2.459.gbcd45b4.dirty

2013-04-09 07:08:24

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 0/2] hfs/hfsplus: Modernize logging styles

On Mon, 2013-04-08 at 09:37 -0700, Joe Perches wrote:
> Joe Perches (2):
> hfs/hfsplus: Convert dprint to hfs_dbg
> hfs/hfsplus: Convert printks to pr_<level>
>

Thank you for your efforts. It is a good work.

But I have some additional suggestions:
(1) I think that it makes sense to use no_printk() for the case when we
don't need in debug output.
(2) I think that it is really necessary to add info about file and line
number for the case of debug output.

As I know Hin Tak has some code for dynamic debugging. I think that it
is a time for publish this work also. But I suppose that we can have
opportunity to choose old-fashioned HFS debugging output or dynamic
debug by means of declaration of special macro definition for every
case. I mean constant for every case (static debug, dynamic debug, no
debug).

Thanks,
Vyacheslav Dubeyko.

> fs/hfs/bfind.c | 10 +++++----
> fs/hfs/bitmap.c | 4 ++--
> fs/hfs/bnode.c | 39 ++++++++++++++++++----------------
> fs/hfs/brec.c | 19 +++++++++--------
> fs/hfs/btree.c | 31 ++++++++++++++-------------
> fs/hfs/catalog.c | 12 ++++++-----
> fs/hfs/dir.c | 12 +++++------
> fs/hfs/extent.c | 20 ++++++++++--------
> fs/hfs/hfs_fs.h | 20 ++++++++++++++++--
> fs/hfs/inode.c | 4 ++--
> fs/hfs/mdb.c | 23 ++++++++++----------
> fs/hfs/super.c | 43 +++++++++++++++++++------------------
> fs/hfsplus/attributes.c | 26 +++++++++++------------
> fs/hfsplus/bfind.c | 6 +++---
> fs/hfsplus/bitmap.c | 12 +++++------
> fs/hfsplus/bnode.c | 36 +++++++++++++++----------------
> fs/hfsplus/brec.c | 14 ++++++-------
> fs/hfsplus/btree.c | 29 +++++++++++++------------
> fs/hfsplus/catalog.c | 11 +++++-----
> fs/hfsplus/dir.c | 14 ++++++-------
> fs/hfsplus/extents.c | 32 ++++++++++++++--------------
> fs/hfsplus/hfsplus_fs.h | 20 +++++++++++++++---
> fs/hfsplus/inode.c | 4 ++--
> fs/hfsplus/options.c | 22 +++++++++----------
> fs/hfsplus/super.c | 56 +++++++++++++++++++------------------------------
> fs/hfsplus/wrapper.c | 8 +++----
> fs/hfsplus/xattr.c | 41 ++++++++++++++++++------------------
> 27 files changed, 296 insertions(+), 272 deletions(-)
>

2013-04-09 07:08:35

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

On Mon, 2013-04-08 at 09:37 -0700, Joe Perches wrote:
> Use a more current logging style.
>
> Rename macro and uses.
> Add do {} while (0) to macro.
> Add DBG_ to macro.
> Add and use hfs_dbg_cont variant where appropriate.
>

I think that if we begin to modify messages subsystem then it makes
sense to fix all warnings:

WARNING: %Ld/%Lu are not-standard C, use %lld/%llu
#361: FILE: fs/hfs/extent.c:464:
+ hfs_dbg(INODE, "truncate: %lu, %Lu -> %Lu\n",

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#380: FILE: fs/hfs/hfs_fs.h:40:
+ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \

WARNING: Prefer netdev_cont(netdev, ... then dev_cont(dev, ... then pr_cont(... to printk(KERN_CONT ...
#386: FILE: fs/hfs/hfs_fs.h:46:
+ printk(KERN_CONT fmt, ##__VA_ARGS__); \

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#835: FILE: fs/hfsplus/hfsplus_fs.h:38:
+ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \

WARNING: Prefer netdev_cont(netdev, ... then dev_cont(dev, ... then pr_cont(... to printk(KERN_CONT ...
#841: FILE: fs/hfsplus/hfsplus_fs.h:44:
+ printk(KERN_CONT fmt, ##__VA_ARGS__); \

total: 0 errors, 5 warnings, 674 lines checked

> Signed-off-by: Joe Perches <[email protected]>
> ---
> fs/hfs/bfind.c | 6 ++++--
> fs/hfs/bitmap.c | 4 ++--
> fs/hfs/bnode.c | 35 +++++++++++++++++++----------------
> fs/hfs/brec.c | 11 +++++++----
> fs/hfs/btree.c | 2 +-
> fs/hfs/catalog.c | 8 +++++---
> fs/hfs/extent.c | 20 +++++++++++---------
> fs/hfs/hfs_fs.h | 14 ++++++++++++--
> fs/hfs/inode.c | 4 ++--
> fs/hfsplus/attributes.c | 8 ++++----
> fs/hfsplus/bfind.c | 4 ++--
> fs/hfsplus/bitmap.c | 10 +++++-----
> fs/hfsplus/bnode.c | 30 +++++++++++++++---------------
> fs/hfsplus/brec.c | 10 +++++-----
> fs/hfsplus/btree.c | 4 ++--
> fs/hfsplus/catalog.c | 7 +++----
> fs/hfsplus/extents.c | 26 +++++++++++++-------------
> fs/hfsplus/hfsplus_fs.h | 14 +++++++++++---
> fs/hfsplus/super.c | 8 ++++----
> 19 files changed, 127 insertions(+), 98 deletions(-)
>
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index 571abe9..e928f6c 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -22,7 +22,8 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
> return -ENOMEM;
> fd->search_key = ptr;
> fd->key = ptr + tree->max_key_len + 2;
> - dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));


I think that changing DBG_BNODE_REFS on BNODE_REFS (and so on) is not
very good idea, from my point of view. Because it can be a basis for
some ambiguity and misunderstanding (during a search for example). I
understand that we reduce constant in length. But I doubt that this
changing makes sense.

Thanks,
Vyacheslav Dubeyko.

> + hfs_dbg(BNODE_REFS, "find_init: %d (%p)\n",
> + tree->cnid, __builtin_return_address(0));
> mutex_lock(&tree->tree_lock);
> return 0;
> }
> @@ -31,7 +32,8 @@ void hfs_find_exit(struct hfs_find_data *fd)
> {
> hfs_bnode_put(fd->bnode);
> kfree(fd->search_key);
> - dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
> + hfs_dbg(BNODE_REFS, "find_exit: %d (%p)\n",
> + fd->tree->cnid, __builtin_return_address(0));
> mutex_unlock(&fd->tree->tree_lock);
> fd->tree = NULL;
> }
> diff --git a/fs/hfs/bitmap.c b/fs/hfs/bitmap.c
> index c6e9736..28307bc 100644
> --- a/fs/hfs/bitmap.c
> +++ b/fs/hfs/bitmap.c
> @@ -158,7 +158,7 @@ u32 hfs_vbm_search_free(struct super_block *sb, u32 goal, u32 *num_bits)
> }
> }
>
> - dprint(DBG_BITMAP, "alloc_bits: %u,%u\n", pos, *num_bits);
> + hfs_dbg(BITMAP, "alloc_bits: %u,%u\n", pos, *num_bits);
> HFS_SB(sb)->free_ablocks -= *num_bits;
> hfs_bitmap_dirty(sb);
> out:
> @@ -200,7 +200,7 @@ int hfs_clear_vbm_bits(struct super_block *sb, u16 start, u16 count)
> if (!count)
> return 0;
>
> - dprint(DBG_BITMAP, "clear_bits: %u,%u\n", start, count);
> + hfs_dbg(BITMAP, "clear_bits: %u,%u\n", start, count);
> /* are all of the bits in range? */
> if ((start + count) > HFS_SB(sb)->fs_ablocks)
> return -2;
> diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
> index cdb41a1..8693919 100644
> --- a/fs/hfs/bnode.c
> +++ b/fs/hfs/bnode.c
> @@ -100,7 +100,7 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
> struct hfs_btree *tree;
> struct page *src_page, *dst_page;
>
> - dprint(DBG_BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
> + hfs_dbg(BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
> if (!len)
> return;
> tree = src_node->tree;
> @@ -120,7 +120,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
> struct page *page;
> void *ptr;
>
> - dprint(DBG_BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
> + hfs_dbg(BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
> if (!len)
> return;
> src += node->page_offset;
> @@ -138,16 +138,16 @@ void hfs_bnode_dump(struct hfs_bnode *node)
> __be32 cnid;
> int i, off, key_off;
>
> - dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this);
> + hfs_dbg(BNODE_MOD, "bnode: %d\n", node->this);
> hfs_bnode_read(node, &desc, 0, sizeof(desc));
> - dprint(DBG_BNODE_MOD, "%d, %d, %d, %d, %d\n",
> + hfs_dbg(BNODE_MOD, "%d, %d, %d, %d, %d\n",
> be32_to_cpu(desc.next), be32_to_cpu(desc.prev),
> desc.type, desc.height, be16_to_cpu(desc.num_recs));
>
> off = node->tree->node_size - 2;
> for (i = be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
> key_off = hfs_bnode_read_u16(node, off);
> - dprint(DBG_BNODE_MOD, " %d", key_off);
> + hfs_dbg_cont(BNODE_MOD, " %d", key_off);
> if (i && node->type == HFS_NODE_INDEX) {
> int tmp;
>
> @@ -155,17 +155,18 @@ void hfs_bnode_dump(struct hfs_bnode *node)
> tmp = (hfs_bnode_read_u8(node, key_off) | 1) + 1;
> else
> tmp = node->tree->max_key_len + 1;
> - dprint(DBG_BNODE_MOD, " (%d,%d", tmp, hfs_bnode_read_u8(node, key_off));
> + hfs_dbg_cont(BNODE_MOD, " (%d,%d",
> + tmp, hfs_bnode_read_u8(node, key_off));
> hfs_bnode_read(node, &cnid, key_off + tmp, 4);
> - dprint(DBG_BNODE_MOD, ",%d)", be32_to_cpu(cnid));
> + hfs_dbg_cont(BNODE_MOD, ",%d)", be32_to_cpu(cnid));
> } else if (i && node->type == HFS_NODE_LEAF) {
> int tmp;
>
> tmp = hfs_bnode_read_u8(node, key_off);
> - dprint(DBG_BNODE_MOD, " (%d)", tmp);
> + hfs_dbg_cont(BNODE_MOD, " (%d)", tmp);
> }
> }
> - dprint(DBG_BNODE_MOD, "\n");
> + hfs_dbg_cont(BNODE_MOD, "\n");
> }
>
> void hfs_bnode_unlink(struct hfs_bnode *node)
> @@ -257,8 +258,8 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
> node->this = cnid;
> set_bit(HFS_BNODE_NEW, &node->flags);
> atomic_set(&node->refcnt, 1);
> - dprint(DBG_BNODE_REFS, "new_node(%d:%d): 1\n",
> - node->tree->cnid, node->this);
> + hfs_dbg(BNODE_REFS, "new_node(%d:%d): 1\n",
> + node->tree->cnid, node->this);
> init_waitqueue_head(&node->lock_wq);
> spin_lock(&tree->hash_lock);
> node2 = hfs_bnode_findhash(tree, cnid);
> @@ -301,7 +302,7 @@ void hfs_bnode_unhash(struct hfs_bnode *node)
> {
> struct hfs_bnode **p;
>
> - dprint(DBG_BNODE_REFS, "remove_node(%d:%d): %d\n",
> + hfs_dbg(BNODE_REFS, "remove_node(%d:%d): %d\n",
> node->tree->cnid, node->this, atomic_read(&node->refcnt));
> for (p = &node->tree->node_hash[hfs_bnode_hash(node->this)];
> *p && *p != node; p = &(*p)->next_hash)
> @@ -443,8 +444,9 @@ void hfs_bnode_get(struct hfs_bnode *node)
> {
> if (node) {
> atomic_inc(&node->refcnt);
> - dprint(DBG_BNODE_REFS, "get_node(%d:%d): %d\n",
> - node->tree->cnid, node->this, atomic_read(&node->refcnt));
> + hfs_dbg(BNODE_REFS, "get_node(%d:%d): %d\n",
> + node->tree->cnid, node->this,
> + atomic_read(&node->refcnt));
> }
> }
>
> @@ -455,8 +457,9 @@ void hfs_bnode_put(struct hfs_bnode *node)
> struct hfs_btree *tree = node->tree;
> int i;
>
> - dprint(DBG_BNODE_REFS, "put_node(%d:%d): %d\n",
> - node->tree->cnid, node->this, atomic_read(&node->refcnt));
> + hfs_dbg(BNODE_REFS, "put_node(%d:%d): %d\n",
> + node->tree->cnid, node->this,
> + atomic_read(&node->refcnt));
> BUG_ON(!atomic_read(&node->refcnt));
> if (!atomic_dec_and_lock(&node->refcnt, &tree->hash_lock))
> return;
> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
> index 92fb358..5764257 100644
> --- a/fs/hfs/brec.c
> +++ b/fs/hfs/brec.c
> @@ -94,7 +94,8 @@ again:
> end_rec_off = tree->node_size - (node->num_recs + 1) * 2;
> end_off = hfs_bnode_read_u16(node, end_rec_off);
> end_rec_off -= 2;
> - dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n", rec, size, end_off, end_rec_off);
> + hfs_dbg(BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
> + rec, size, end_off, end_rec_off);
> if (size > end_rec_off - end_off) {
> if (new_node)
> panic("not enough room!\n");
> @@ -190,7 +191,8 @@ again:
> mark_inode_dirty(tree->inode);
> }
> hfs_bnode_dump(node);
> - dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n", fd->record, fd->keylength + fd->entrylength);
> + hfs_dbg(BNODE_MOD, "remove_rec: %d, %d\n",
> + fd->record, fd->keylength + fd->entrylength);
> if (!--node->num_recs) {
> hfs_bnode_unlink(node);
> if (!node->parent)
> @@ -240,7 +242,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
> if (IS_ERR(new_node))
> return new_node;
> hfs_bnode_get(node);
> - dprint(DBG_BNODE_MOD, "split_nodes: %d - %d - %d\n",
> + hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n",
> node->this, new_node->this, node->next);
> new_node->next = node->next;
> new_node->prev = node->this;
> @@ -374,7 +376,8 @@ again:
> newkeylen = (hfs_bnode_read_u8(node, 14) | 1) + 1;
> else
> fd->keylength = newkeylen = tree->max_key_len + 1;
> - dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n", rec, fd->keylength, newkeylen);
> + hfs_dbg(BNODE_MOD, "update_rec: %d, %d, %d\n",
> + rec, fd->keylength, newkeylen);
>
> rec_off = tree->node_size - (rec + 2) * 2;
> end_rec_off = tree->node_size - (parent->num_recs + 1) * 2;
> diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
> index 1cbdeea..07d94ce 100644
> --- a/fs/hfs/btree.c
> +++ b/fs/hfs/btree.c
> @@ -316,7 +316,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
> u32 nidx;
> u8 *data, byte, m;
>
> - dprint(DBG_BNODE_MOD, "btree_free_node: %u\n", node->this);
> + hfs_dbg(BNODE_MOD, "btree_free_node: %u\n", node->this);
> tree = node->tree;
> nidx = node->this;
> node = hfs_bnode_find(tree, 0);
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index 424b033..76cfb17 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -87,7 +87,8 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
> int entry_size;
> int err;
>
> - dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n", str->name, cnid, inode->i_nlink);
> + hfs_dbg(CAT_MOD, "create_cat: %s,%u(%d)\n",
> + str->name, cnid, inode->i_nlink);
> if (dir->i_size >= HFS_MAX_VALENCE)
> return -ENOSPC;
>
> @@ -212,7 +213,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
> struct list_head *pos;
> int res, type;
>
> - dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
> + hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
> sb = dir->i_sb;
> hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>
> @@ -278,7 +279,8 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
> int entry_size, type;
> int err;
>
> - dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
> + hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
> + cnid, src_dir->i_ino, src_name->name,
> dst_dir->i_ino, dst_name->name);
> sb = src_dir->i_sb;
> hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
> index a67955a..6e63a4d 100644
> --- a/fs/hfs/extent.c
> +++ b/fs/hfs/extent.c
> @@ -195,11 +195,12 @@ static void hfs_dump_extent(struct hfs_extent *extent)
> {
> int i;
>
> - dprint(DBG_EXTENT, " ");
> + hfs_dbg(EXTENT, " ");
> for (i = 0; i < 3; i++)
> - dprint(DBG_EXTENT, " %u:%u", be16_to_cpu(extent[i].block),
> - be16_to_cpu(extent[i].count));
> - dprint(DBG_EXTENT, "\n");
> + hfs_dbg_cont(EXTENT, " %u:%u",
> + be16_to_cpu(extent[i].block),
> + be16_to_cpu(extent[i].count));
> + hfs_dbg_cont(EXTENT, "\n");
> }
>
> static int hfs_add_extent(struct hfs_extent *extent, u16 offset,
> @@ -392,10 +393,10 @@ int hfs_extend_file(struct inode *inode)
> goto out;
> }
>
> - dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
> + hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
> if (HFS_I(inode)->alloc_blocks == HFS_I(inode)->first_blocks) {
> if (!HFS_I(inode)->first_blocks) {
> - dprint(DBG_EXTENT, "first extents\n");
> + hfs_dbg(EXTENT, "first extents\n");
> /* no extents yet */
> HFS_I(inode)->first_extents[0].block = cpu_to_be16(start);
> HFS_I(inode)->first_extents[0].count = cpu_to_be16(len);
> @@ -437,7 +438,7 @@ out:
> return res;
>
> insert_extent:
> - dprint(DBG_EXTENT, "insert new extent\n");
> + hfs_dbg(EXTENT, "insert new extent\n");
> hfs_ext_write_extent(inode);
>
> memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
> @@ -460,8 +461,9 @@ void hfs_file_truncate(struct inode *inode)
> u32 size;
> int res;
>
> - dprint(DBG_INODE, "truncate: %lu, %Lu -> %Lu\n", inode->i_ino,
> - (long long)HFS_I(inode)->phys_size, inode->i_size);
> + hfs_dbg(INODE, "truncate: %lu, %Lu -> %Lu\n",
> + inode->i_ino, (long long)HFS_I(inode)->phys_size,
> + inode->i_size);
> if (inode->i_size > HFS_I(inode)->phys_size) {
> struct address_space *mapping = inode->i_mapping;
> void *fsdata;
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index 693df9f..cf088e0 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -34,8 +34,18 @@
> //#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
> #define DBG_MASK (0)
>
> -#define dprint(flg, fmt, args...) \
> - if (flg & DBG_MASK) printk(fmt , ## args)
> +#define hfs_dbg(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
> +} while (0)
> +
> +#define hfs_dbg_cont(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_CONT fmt, ##__VA_ARGS__); \
> +} while (0)
> +
>
> /*
> * struct hfs_inode_info
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index a9d60d4..d999db7 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -238,7 +238,7 @@ void hfs_delete_inode(struct inode *inode)
> {
> struct super_block *sb = inode->i_sb;
>
> - dprint(DBG_INODE, "delete_inode: %lu\n", inode->i_ino);
> + hfs_dbg(INODE, "delete_inode: %lu\n", inode->i_ino);
> if (S_ISDIR(inode->i_mode)) {
> HFS_SB(sb)->folder_count--;
> if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
> @@ -418,7 +418,7 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
> struct hfs_find_data fd;
> hfs_cat_rec rec;
>
> - dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
> + hfs_dbg(INODE, "hfs_write_inode: %lu\n", inode->i_ino);
> hfs_ext_write_extent(inode);
>
> if (inode->i_ino < HFS_FIRSTUSER_CNID) {
> diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
> index 8d691f1..2043b50 100644
> --- a/fs/hfsplus/attributes.c
> +++ b/fs/hfsplus/attributes.c
> @@ -166,7 +166,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
> {
> int err = 0;
>
> - dprint(DBG_ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);
> + hfs_dbg(ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> @@ -228,7 +228,7 @@ int hfsplus_create_attr(struct inode *inode,
> int entry_size;
> int err;
>
> - dprint(DBG_ATTR_MOD, "create_attr: %s,%ld\n",
> + hfs_dbg(ATTR_MOD, "create_attr: %s,%ld\n",
> name ? name : NULL, inode->i_ino);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> @@ -328,7 +328,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
> struct super_block *sb = inode->i_sb;
> struct hfs_find_data fd;
>
> - dprint(DBG_ATTR_MOD, "delete_attr: %s,%ld\n",
> + hfs_dbg(ATTR_MOD, "delete_attr: %s,%ld\n",
> name ? name : NULL, inode->i_ino);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> @@ -369,7 +369,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
> int err = 0;
> struct hfs_find_data fd;
>
> - dprint(DBG_ATTR_MOD, "delete_all_attrs: %d\n", cnid);
> + hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);
>
> if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
> printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> index bbfdc17..d27f37f 100644
> --- a/fs/hfsplus/bfind.c
> +++ b/fs/hfsplus/bfind.c
> @@ -22,7 +22,7 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
> return -ENOMEM;
> fd->search_key = ptr;
> fd->key = ptr + tree->max_key_len + 2;
> - dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n",
> + hfs_dbg(BNODE_REFS, "find_init: %d (%p)\n",
> tree->cnid, __builtin_return_address(0));
> switch (tree->cnid) {
> case HFSPLUS_CAT_CNID:
> @@ -44,7 +44,7 @@ void hfs_find_exit(struct hfs_find_data *fd)
> {
> hfs_bnode_put(fd->bnode);
> kfree(fd->search_key);
> - dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n",
> + hfs_dbg(BNODE_REFS, "find_exit: %d (%p)\n",
> fd->tree->cnid, __builtin_return_address(0));
> mutex_unlock(&fd->tree->tree_lock);
> fd->tree = NULL;
> diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
> index 6feefc0..7da6d46 100644
> --- a/fs/hfsplus/bitmap.c
> +++ b/fs/hfsplus/bitmap.c
> @@ -30,7 +30,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size,
> if (!len)
> return size;
>
> - dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
> + hfs_dbg(BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
> mutex_lock(&sbi->alloc_mutex);
> mapping = sbi->alloc_file->i_mapping;
> page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
> @@ -89,14 +89,14 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size,
> else
> end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32;
> }
> - dprint(DBG_BITMAP, "bitmap full\n");
> + hfs_dbg(BITMAP, "bitmap full\n");
> start = size;
> goto out;
>
> found:
> start = offset + (curr - pptr) * 32 + i;
> if (start >= size) {
> - dprint(DBG_BITMAP, "bitmap full\n");
> + hfs_dbg(BITMAP, "bitmap full\n");
> goto out;
> }
> /* do any partial u32 at the start */
> @@ -154,7 +154,7 @@ done:
> *max = offset + (curr - pptr) * 32 + i - start;
> sbi->free_blocks -= *max;
> hfsplus_mark_mdb_dirty(sb);
> - dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
> + hfs_dbg(BITMAP, "-> %u,%u\n", start, *max);
> out:
> mutex_unlock(&sbi->alloc_mutex);
> return start;
> @@ -173,7 +173,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
> if (!count)
> return 0;
>
> - dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
> + hfs_dbg(BITMAP, "block_free: %u,%u\n", offset, count);
> /* are all of the bits in range? */
> if ((offset + count) > sbi->total_blocks)
> return -ENOENT;
> diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
> index f31ac6f..1ca9304 100644
> --- a/fs/hfsplus/bnode.c
> +++ b/fs/hfsplus/bnode.c
> @@ -130,7 +130,7 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,
> struct page **src_page, **dst_page;
> int l;
>
> - dprint(DBG_BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
> + hfs_dbg(BNODE_MOD, "copybytes: %u,%u,%u\n", dst, src, len);
> if (!len)
> return;
> tree = src_node->tree;
> @@ -188,7 +188,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
> struct page **src_page, **dst_page;
> int l;
>
> - dprint(DBG_BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
> + hfs_dbg(BNODE_MOD, "movebytes: %u,%u,%u\n", dst, src, len);
> if (!len)
> return;
> src += node->page_offset;
> @@ -302,16 +302,16 @@ void hfs_bnode_dump(struct hfs_bnode *node)
> __be32 cnid;
> int i, off, key_off;
>
> - dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this);
> + hfs_dbg(BNODE_MOD, "bnode: %d\n", node->this);
> hfs_bnode_read(node, &desc, 0, sizeof(desc));
> - dprint(DBG_BNODE_MOD, "%d, %d, %d, %d, %d\n",
> + hfs_dbg(BNODE_MOD, "%d, %d, %d, %d, %d\n",
> be32_to_cpu(desc.next), be32_to_cpu(desc.prev),
> desc.type, desc.height, be16_to_cpu(desc.num_recs));
>
> off = node->tree->node_size - 2;
> for (i = be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
> key_off = hfs_bnode_read_u16(node, off);
> - dprint(DBG_BNODE_MOD, " %d", key_off);
> + hfs_dbg(BNODE_MOD, " %d", key_off);
> if (i && node->type == HFS_NODE_INDEX) {
> int tmp;
>
> @@ -320,17 +320,17 @@ void hfs_bnode_dump(struct hfs_bnode *node)
> tmp = hfs_bnode_read_u16(node, key_off) + 2;
> else
> tmp = node->tree->max_key_len + 2;
> - dprint(DBG_BNODE_MOD, " (%d", tmp);
> + hfs_dbg_cont(BNODE_MOD, " (%d", tmp);
> hfs_bnode_read(node, &cnid, key_off + tmp, 4);
> - dprint(DBG_BNODE_MOD, ",%d)", be32_to_cpu(cnid));
> + hfs_dbg_cont(BNODE_MOD, ",%d)", be32_to_cpu(cnid));
> } else if (i && node->type == HFS_NODE_LEAF) {
> int tmp;
>
> tmp = hfs_bnode_read_u16(node, key_off);
> - dprint(DBG_BNODE_MOD, " (%d)", tmp);
> + hfs_dbg_cont(BNODE_MOD, " (%d)", tmp);
> }
> }
> - dprint(DBG_BNODE_MOD, "\n");
> + hfs_dbg_cont(BNODE_MOD, "\n");
> }
>
> void hfs_bnode_unlink(struct hfs_bnode *node)
> @@ -366,7 +366,7 @@ void hfs_bnode_unlink(struct hfs_bnode *node)
>
> /* move down? */
> if (!node->prev && !node->next)
> - dprint(DBG_BNODE_MOD, "hfs_btree_del_level\n");
> + hfs_dbg(BNODE_MOD, "hfs_btree_del_level\n");
> if (!node->parent) {
> tree->root = 0;
> tree->depth = 0;
> @@ -425,8 +425,8 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
> node->this = cnid;
> set_bit(HFS_BNODE_NEW, &node->flags);
> atomic_set(&node->refcnt, 1);
> - dprint(DBG_BNODE_REFS, "new_node(%d:%d): 1\n",
> - node->tree->cnid, node->this);
> + hfs_dbg(BNODE_REFS, "new_node(%d:%d): 1\n",
> + node->tree->cnid, node->this);
> init_waitqueue_head(&node->lock_wq);
> spin_lock(&tree->hash_lock);
> node2 = hfs_bnode_findhash(tree, cnid);
> @@ -470,7 +470,7 @@ void hfs_bnode_unhash(struct hfs_bnode *node)
> {
> struct hfs_bnode **p;
>
> - dprint(DBG_BNODE_REFS, "remove_node(%d:%d): %d\n",
> + hfs_dbg(BNODE_REFS, "remove_node(%d:%d): %d\n",
> node->tree->cnid, node->this, atomic_read(&node->refcnt));
> for (p = &node->tree->node_hash[hfs_bnode_hash(node->this)];
> *p && *p != node; p = &(*p)->next_hash)
> @@ -620,7 +620,7 @@ void hfs_bnode_get(struct hfs_bnode *node)
> {
> if (node) {
> atomic_inc(&node->refcnt);
> - dprint(DBG_BNODE_REFS, "get_node(%d:%d): %d\n",
> + hfs_dbg(BNODE_REFS, "get_node(%d:%d): %d\n",
> node->tree->cnid, node->this,
> atomic_read(&node->refcnt));
> }
> @@ -633,7 +633,7 @@ void hfs_bnode_put(struct hfs_bnode *node)
> struct hfs_btree *tree = node->tree;
> int i;
>
> - dprint(DBG_BNODE_REFS, "put_node(%d:%d): %d\n",
> + hfs_dbg(BNODE_REFS, "put_node(%d:%d): %d\n",
> node->tree->cnid, node->this,
> atomic_read(&node->refcnt));
> BUG_ON(!atomic_read(&node->refcnt));
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index 298d4e4..e238ba8 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -90,7 +90,7 @@ again:
> end_rec_off = tree->node_size - (node->num_recs + 1) * 2;
> end_off = hfs_bnode_read_u16(node, end_rec_off);
> end_rec_off -= 2;
> - dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
> + hfs_dbg(BNODE_MOD, "insert_rec: %d, %d, %d, %d\n",
> rec, size, end_off, end_rec_off);
> if (size > end_rec_off - end_off) {
> if (new_node)
> @@ -191,7 +191,7 @@ again:
> mark_inode_dirty(tree->inode);
> }
> hfs_bnode_dump(node);
> - dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n",
> + hfs_dbg(BNODE_MOD, "remove_rec: %d, %d\n",
> fd->record, fd->keylength + fd->entrylength);
> if (!--node->num_recs) {
> hfs_bnode_unlink(node);
> @@ -244,7 +244,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
> if (IS_ERR(new_node))
> return new_node;
> hfs_bnode_get(node);
> - dprint(DBG_BNODE_MOD, "split_nodes: %d - %d - %d\n",
> + hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n",
> node->this, new_node->this, node->next);
> new_node->next = node->next;
> new_node->prev = node->this;
> @@ -379,7 +379,7 @@ again:
> newkeylen = hfs_bnode_read_u16(node, 14) + 2;
> else
> fd->keylength = newkeylen = tree->max_key_len + 2;
> - dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n",
> + hfs_dbg(BNODE_MOD, "update_rec: %d, %d, %d\n",
> rec, fd->keylength, newkeylen);
>
> rec_off = tree->node_size - (rec + 2) * 2;
> @@ -391,7 +391,7 @@ again:
> end_off = hfs_bnode_read_u16(parent, end_rec_off);
> if (end_rec_off - end_off < diff) {
>
> - dprint(DBG_BNODE_MOD, "hfs: splitting index node.\n");
> + hfs_dbg(BNODE_MOD, "splitting index node\n");
> fd->bnode = parent;
> new_node = hfs_bnode_split(fd);
> if (IS_ERR(new_node))
> diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
> index efb689c..c2fa4bf 100644
> --- a/fs/hfsplus/btree.c
> +++ b/fs/hfsplus/btree.c
> @@ -303,7 +303,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
> kunmap(*pagep);
> nidx = node->next;
> if (!nidx) {
> - dprint(DBG_BNODE_MOD, "hfs: create new bmap node.\n");
> + hfs_dbg(BNODE_MOD, "create new bmap node\n");
> next_node = hfs_bmap_new_bmap(node, idx);
> } else
> next_node = hfs_bnode_find(tree, nidx);
> @@ -329,7 +329,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
> u32 nidx;
> u8 *data, byte, m;
>
> - dprint(DBG_BNODE_MOD, "btree_free_node: %u\n", node->this);
> + hfs_dbg(BNODE_MOD, "btree_free_node: %u\n", node->this);
> BUG_ON(!node->this);
> tree = node->tree;
> nidx = node->this;
> diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
> index 840d71e..12cea23 100644
> --- a/fs/hfsplus/catalog.c
> +++ b/fs/hfsplus/catalog.c
> @@ -212,7 +212,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
> int entry_size;
> int err;
>
> - dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n",
> + hfs_dbg(CAT_MOD, "create_cat: %s,%u(%d)\n",
> str->name, cnid, inode->i_nlink);
> err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
> if (err)
> @@ -271,8 +271,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
> int err, off;
> u16 type;
>
> - dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n",
> - str ? str->name : NULL, cnid);
> + hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
> err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
> if (err)
> return err;
> @@ -361,7 +360,7 @@ int hfsplus_rename_cat(u32 cnid,
> int entry_size, type;
> int err;
>
> - dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
> + hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
> cnid, src_dir->i_ino, src_name->name,
> dst_dir->i_ino, dst_name->name);
> err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &src_fd);
> diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
> index a94f0f7..7541731 100644
> --- a/fs/hfsplus/extents.c
> +++ b/fs/hfsplus/extents.c
> @@ -265,7 +265,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
> mutex_unlock(&hip->extents_lock);
>
> done:
> - dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n",
> + hfs_dbg(EXTENT, "get_block(%lu): %llu - %u\n",
> inode->i_ino, (long long)iblock, dblock);
>
> mask = (1 << sbi->fs_shift) - 1;
> @@ -288,11 +288,12 @@ static void hfsplus_dump_extent(struct hfsplus_extent *extent)
> {
> int i;
>
> - dprint(DBG_EXTENT, " ");
> + hfs_dbg(EXTENT, " ");
> for (i = 0; i < 8; i++)
> - dprint(DBG_EXTENT, " %u:%u", be32_to_cpu(extent[i].start_block),
> - be32_to_cpu(extent[i].block_count));
> - dprint(DBG_EXTENT, "\n");
> + hfs_dbg_cont(EXTENT, " %u:%u",
> + be32_to_cpu(extent[i].start_block),
> + be32_to_cpu(extent[i].block_count));
> + hfs_dbg_cont(EXTENT, "\n");
> }
>
> static int hfsplus_add_extent(struct hfsplus_extent *extent, u32 offset,
> @@ -349,7 +350,7 @@ found:
> err = hfsplus_block_free(sb, start, count);
> if (err) {
> printk(KERN_ERR "hfs: can't free extent\n");
> - dprint(DBG_EXTENT, " start: %u count: %u\n",
> + hfs_dbg(EXTENT, " start: %u count: %u\n",
> start, count);
> }
> extent->block_count = 0;
> @@ -360,7 +361,7 @@ found:
> err = hfsplus_block_free(sb, start + count, block_nr);
> if (err) {
> printk(KERN_ERR "hfs: can't free extent\n");
> - dprint(DBG_EXTENT, " start: %u count: %u\n",
> + hfs_dbg(EXTENT, " start: %u count: %u\n",
> start, count);
> }
> extent->block_count = cpu_to_be32(count);
> @@ -459,11 +460,11 @@ int hfsplus_file_extend(struct inode *inode)
> }
> }
>
> - dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
> + hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
>
> if (hip->alloc_blocks <= hip->first_blocks) {
> if (!hip->first_blocks) {
> - dprint(DBG_EXTENT, "first extents\n");
> + hfs_dbg(EXTENT, "first extents\n");
> /* no extents yet */
> hip->first_extents[0].start_block = cpu_to_be32(start);
> hip->first_extents[0].block_count = cpu_to_be32(len);
> @@ -500,7 +501,7 @@ out:
> return res;
>
> insert_extent:
> - dprint(DBG_EXTENT, "insert new extent\n");
> + hfs_dbg(EXTENT, "insert new extent\n");
> res = hfsplus_ext_write_extent_locked(inode);
> if (res)
> goto out;
> @@ -525,9 +526,8 @@ void hfsplus_file_truncate(struct inode *inode)
> u32 alloc_cnt, blk_cnt, start;
> int res;
>
> - dprint(DBG_INODE, "truncate: %lu, %llu -> %llu\n",
> - inode->i_ino, (long long)hip->phys_size,
> - inode->i_size);
> + hfs_dbg(INODE, "truncate: %lu, %llu -> %llu\n",
> + inode->i_ino, (long long)hip->phys_size, inode->i_size);
>
> if (inode->i_size > hip->phys_size) {
> struct address_space *mapping = inode->i_mapping;
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 05b11f3..910ea98e 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -32,9 +32,17 @@
> #endif
> #define DBG_MASK (0)
>
> -#define dprint(flg, fmt, args...) \
> - if (flg & DBG_MASK) \
> - printk(fmt , ## args)
> +#define hfs_dbg(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
> +} while (0)
> +
> +#define hfs_dbg_cont(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_CONT fmt, ##__VA_ARGS__); \
> +} while (0)
>
> /* Runtime config options */
> #define HFSPLUS_DEF_CR_TYPE 0x3F3F3F3F /* '????' */
> diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
> index 7b87284..4886fd3 100644
> --- a/fs/hfsplus/super.c
> +++ b/fs/hfsplus/super.c
> @@ -145,7 +145,7 @@ static int hfsplus_write_inode(struct inode *inode,
> {
> int err;
>
> - dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
> + hfs_dbg(INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
>
> err = hfsplus_ext_write_extent(inode);
> if (err)
> @@ -160,7 +160,7 @@ static int hfsplus_write_inode(struct inode *inode,
>
> static void hfsplus_evict_inode(struct inode *inode)
> {
> - dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
> + hfs_dbg(INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
> truncate_inode_pages(&inode->i_data, 0);
> clear_inode(inode);
> if (HFSPLUS_IS_RSRC(inode)) {
> @@ -179,7 +179,7 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait)
> if (!wait)
> return 0;
>
> - dprint(DBG_SUPER, "hfsplus_sync_fs\n");
> + hfs_dbg(SUPER, "hfsplus_sync_fs\n");
>
> /*
> * Explicitly write out the special metadata inodes.
> @@ -275,7 +275,7 @@ static void hfsplus_put_super(struct super_block *sb)
> {
> struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
>
> - dprint(DBG_SUPER, "hfsplus_put_super\n");
> + hfs_dbg(SUPER, "hfsplus_put_super\n");
>
> cancel_delayed_work_sync(&sbi->sync_work);
>

2013-04-09 07:08:43

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 2/2] hfs/hfsplus: Convert printks to pr_<level>

On Mon, 2013-04-08 at 09:37 -0700, Joe Perches wrote:
> Use a more current logging style.
>
> Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> hfsplus now uses "hfsplus: " for all messages.
> Coalesce formats.
> Prefix debugging messages too.
>

I think that if we begin to modify messages subsystem then it makes
sense to fix all warnings:

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#138: FILE: fs/hfs/brec.c:389:
+ printk(KERN_DEBUG "splitting index node...\n");

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#202: FILE: fs/hfs/btree.c:293:
+ printk(KERN_DEBUG "create new bmap node...\n");

ERROR: do not use C99 // comments
#272: FILE: fs/hfs/dir.c:92:
+ // pr_err("truncated catalog thread\n");

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#340: FILE: fs/hfs/hfs_fs.h:46:
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \

WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
#1014: FILE: fs/hfsplus/hfsplus_fs.h:44:
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \

total: 1 errors, 4 warnings, 1226 lines checked

Thanks,
Vyacheslav Dubeyko.

> Signed-off-by: Joe Perches <[email protected]>
> ---
> fs/hfs/bfind.c | 4 ++--
> fs/hfs/bnode.c | 4 ++--
> fs/hfs/brec.c | 8 +++-----
> fs/hfs/btree.c | 29 ++++++++++++++++-------------
> fs/hfs/catalog.c | 4 ++--
> fs/hfs/dir.c | 12 ++++++------
> fs/hfs/hfs_fs.h | 22 ++++++++++++++--------
> fs/hfs/mdb.c | 23 +++++++++++------------
> fs/hfs/super.c | 43 +++++++++++++++++++++----------------------
> fs/hfsplus/attributes.c | 18 +++++++++---------
> fs/hfsplus/bfind.c | 2 +-
> fs/hfsplus/bitmap.c | 2 +-
> fs/hfsplus/bnode.c | 6 +++---
> fs/hfsplus/brec.c | 4 ++--
> fs/hfsplus/btree.c | 25 ++++++++++++-------------
> fs/hfsplus/catalog.c | 4 ++--
> fs/hfsplus/dir.c | 14 +++++++-------
> fs/hfsplus/extents.c | 6 +++---
> fs/hfsplus/hfsplus_fs.h | 22 ++++++++++++++--------
> fs/hfsplus/inode.c | 4 ++--
> fs/hfsplus/options.c | 22 +++++++++++-----------
> fs/hfsplus/super.c | 48 ++++++++++++++++++------------------------------
> fs/hfsplus/wrapper.c | 8 +++-----
> fs/hfsplus/xattr.c | 41 ++++++++++++++++++++---------------------
> 24 files changed, 185 insertions(+), 190 deletions(-)
>
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index e928f6c..de69d8a 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -137,8 +137,8 @@ int hfs_brec_find(struct hfs_find_data *fd)
> return res;
>
> invalid:
> - printk(KERN_ERR "hfs: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
> - height, bnode->height, bnode->type, nidx, parent);
> + pr_err("inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
> + height, bnode->height, bnode->type, nidx, parent);
> res = -EIO;
> release:
> hfs_bnode_put(bnode);
> diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
> index 8693919..f3b1a15 100644
> --- a/fs/hfs/bnode.c
> +++ b/fs/hfs/bnode.c
> @@ -221,7 +221,7 @@ struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid)
> struct hfs_bnode *node;
>
> if (cnid >= tree->node_count) {
> - printk(KERN_ERR "hfs: request for non-existent node %d in B*Tree\n", cnid);
> + pr_err("request for non-existent node %d in B*Tree\n", cnid);
> return NULL;
> }
>
> @@ -244,7 +244,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
> loff_t off;
>
> if (cnid >= tree->node_count) {
> - printk(KERN_ERR "hfs: request for non-existent node %d in B*Tree\n", cnid);
> + pr_err("request for non-existent node %d in B*Tree\n", cnid);
> return NULL;
> }
>
> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
> index 5764257..9f4ee7f 100644
> --- a/fs/hfs/brec.c
> +++ b/fs/hfs/brec.c
> @@ -47,15 +47,13 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
> if (node->tree->attributes & HFS_TREE_BIGKEYS) {
> retval = hfs_bnode_read_u16(node, recoff) + 2;
> if (retval > node->tree->max_key_len + 2) {
> - printk(KERN_ERR "hfs: keylen %d too large\n",
> - retval);
> + pr_err("keylen %d too large\n", retval);
> retval = 0;
> }
> } else {
> retval = (hfs_bnode_read_u8(node, recoff) | 1) + 1;
> if (retval > node->tree->max_key_len + 1) {
> - printk(KERN_ERR "hfs: keylen %d too large\n",
> - retval);
> + pr_err("keylen %d too large\n", retval);
> retval = 0;
> }
> }
> @@ -388,7 +386,7 @@ again:
> end_off = hfs_bnode_read_u16(parent, end_rec_off);
> if (end_rec_off - end_off < diff) {
>
> - printk(KERN_DEBUG "hfs: splitting index node...\n");
> + printk(KERN_DEBUG "splitting index node...\n");
> fd->bnode = parent;
> new_node = hfs_bnode_split(fd);
> if (IS_ERR(new_node))
> diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
> index 07d94ce..1ab19e6 100644
> --- a/fs/hfs/btree.c
> +++ b/fs/hfs/btree.c
> @@ -48,7 +48,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
> mdb->drXTFlSize, be32_to_cpu(mdb->drXTClpSiz));
> if (HFS_I(tree->inode)->alloc_blocks >
> HFS_I(tree->inode)->first_blocks) {
> - printk(KERN_ERR "hfs: invalid btree extent records\n");
> + pr_err("invalid btree extent records\n");
> unlock_new_inode(tree->inode);
> goto free_inode;
> }
> @@ -60,8 +60,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
> mdb->drCTFlSize, be32_to_cpu(mdb->drCTClpSiz));
>
> if (!HFS_I(tree->inode)->first_blocks) {
> - printk(KERN_ERR "hfs: invalid btree extent records "
> - "(0 size).\n");
> + pr_err("invalid btree extent records (0 size)\n");
> unlock_new_inode(tree->inode);
> goto free_inode;
> }
> @@ -100,15 +99,15 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
> switch (id) {
> case HFS_EXT_CNID:
> if (tree->max_key_len != HFS_MAX_EXT_KEYLEN) {
> - printk(KERN_ERR "hfs: invalid extent max_key_len %d\n",
> - tree->max_key_len);
> + pr_err("invalid extent max_key_len %d\n",
> + tree->max_key_len);
> goto fail_page;
> }
> break;
> case HFS_CAT_CNID:
> if (tree->max_key_len != HFS_MAX_CAT_KEYLEN) {
> - printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n",
> - tree->max_key_len);
> + pr_err("invalid catalog max_key_len %d\n",
> + tree->max_key_len);
> goto fail_page;
> }
> break;
> @@ -146,8 +145,9 @@ void hfs_btree_close(struct hfs_btree *tree)
> while ((node = tree->node_hash[i])) {
> tree->node_hash[i] = node->next_hash;
> if (atomic_read(&node->refcnt))
> - printk(KERN_ERR "hfs: node %d:%d still has %d user(s)!\n",
> - node->tree->cnid, node->this, atomic_read(&node->refcnt));
> + pr_err("node %d:%d still has %d user(s)!\n",
> + node->tree->cnid, node->this,
> + atomic_read(&node->refcnt));
> hfs_bnode_free(node);
> tree->node_hash_cnt--;
> }
> @@ -290,7 +290,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
> kunmap(*pagep);
> nidx = node->next;
> if (!nidx) {
> - printk(KERN_DEBUG "hfs: create new bmap node...\n");
> + printk(KERN_DEBUG "create new bmap node...\n");
> next_node = hfs_bmap_new_bmap(node, idx);
> } else
> next_node = hfs_bnode_find(tree, nidx);
> @@ -331,7 +331,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
> hfs_bnode_put(node);
> if (!i) {
> /* panic */;
> - printk(KERN_CRIT "hfs: unable to free bnode %u. bmap not found!\n", node->this);
> + pr_crit("unable to free bnode %u. bmap not found!\n",
> + node->this);
> return;
> }
> node = hfs_bnode_find(tree, i);
> @@ -339,7 +340,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
> return;
> if (node->type != HFS_NODE_MAP) {
> /* panic */;
> - printk(KERN_CRIT "hfs: invalid bmap found! (%u,%d)\n", node->this, node->type);
> + pr_crit("invalid bmap found! (%u,%d)\n",
> + node->this, node->type);
> hfs_bnode_put(node);
> return;
> }
> @@ -352,7 +354,8 @@ void hfs_bmap_free(struct hfs_bnode *node)
> m = 1 << (~nidx & 7);
> byte = data[off];
> if (!(byte & m)) {
> - printk(KERN_CRIT "hfs: trying to free free bnode %u(%d)\n", node->this, node->type);
> + pr_crit("trying to free free bnode %u(%d)\n",
> + node->this, node->type);
> kunmap(page);
> hfs_bnode_put(node);
> return;
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index 76cfb17..80732ab 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -185,14 +185,14 @@ int hfs_cat_find_brec(struct super_block *sb, u32 cnid,
>
> type = rec.type;
> if (type != HFS_CDR_THD && type != HFS_CDR_FTH) {
> - printk(KERN_ERR "hfs: found bad thread record in catalog\n");
> + pr_err("found bad thread record in catalog\n");
> return -EIO;
> }
>
> fd->search_key->cat.ParID = rec.thread.ParID;
> len = fd->search_key->cat.CName.len = rec.thread.CName.len;
> if (len > HFS_NAMELEN) {
> - printk(KERN_ERR "hfs: bad catalog namelength\n");
> + pr_err("bad catalog namelength\n");
> return -EIO;
> }
> memcpy(fd->search_key->cat.CName.name, rec.thread.CName.name, len);
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 5f7f1ab..dbeca24 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -84,12 +84,12 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
>
> hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
> if (entry.type != HFS_CDR_THD) {
> - printk(KERN_ERR "hfs: bad catalog folder thread\n");
> + pr_err("bad catalog folder thread\n");
> err = -EIO;
> goto out;
> }
> //if (fd.entrylength < HFS_MIN_THREAD_SZ) {
> - // printk(KERN_ERR "hfs: truncated catalog thread\n");
> + // pr_err("truncated catalog thread\n");
> // err = -EIO;
> // goto out;
> //}
> @@ -108,7 +108,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
>
> for (;;) {
> if (be32_to_cpu(fd.key->cat.ParID) != inode->i_ino) {
> - printk(KERN_ERR "hfs: walked past end of dir\n");
> + pr_err("walked past end of dir\n");
> err = -EIO;
> goto out;
> }
> @@ -123,7 +123,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
> len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName);
> if (type == HFS_CDR_DIR) {
> if (fd.entrylength < sizeof(struct hfs_cat_dir)) {
> - printk(KERN_ERR "hfs: small dir entry\n");
> + pr_err("small dir entry\n");
> err = -EIO;
> goto out;
> }
> @@ -132,7 +132,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
> break;
> } else if (type == HFS_CDR_FIL) {
> if (fd.entrylength < sizeof(struct hfs_cat_file)) {
> - printk(KERN_ERR "hfs: small file entry\n");
> + pr_err("small file entry\n");
> err = -EIO;
> goto out;
> }
> @@ -140,7 +140,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
> be32_to_cpu(entry.file.FlNum), DT_REG))
> break;
> } else {
> - printk(KERN_ERR "hfs: bad catalog entry type %d\n", type);
> + pr_err("bad catalog entry type %d\n", type);
> err = -EIO;
> goto out;
> }
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index cf088e0..681fc45 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -9,6 +9,12 @@
> #ifndef _LINUX_HFS_FS_H
> #define _LINUX_HFS_FS_H
>
> +#ifdef pr_fmt
> +#undef pr_fmt
> +#endif
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/slab.h>
> #include <linux/types.h>
> #include <linux/mutex.h>
> @@ -34,16 +40,16 @@
> //#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
> #define DBG_MASK (0)
>
> -#define hfs_dbg(flg, fmt, ...) \
> -do { \
> - if (DBG_##flg & DBG_MASK) \
> - printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
> +#define hfs_dbg(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
> } while (0)
>
> -#define hfs_dbg_cont(flg, fmt, ...) \
> -do { \
> - if (DBG_##flg & DBG_MASK) \
> - printk(KERN_CONT fmt, ##__VA_ARGS__); \
> +#define hfs_dbg_cont(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + pr_cont(fmt, ##__VA_ARGS__); \
> } while (0)
>
>
> diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
> index b7ec224..aa3f0d6 100644
> --- a/fs/hfs/mdb.c
> +++ b/fs/hfs/mdb.c
> @@ -48,7 +48,7 @@ static int hfs_get_last_session(struct super_block *sb,
> *start = (sector_t)te.cdte_addr.lba << 2;
> return 0;
> }
> - printk(KERN_ERR "hfs: invalid session number or type of track\n");
> + pr_err("invalid session number or type of track\n");
> return -EINVAL;
> }
> ms_info.addr_format = CDROM_LBA;
> @@ -101,7 +101,7 @@ int hfs_mdb_get(struct super_block *sb)
>
> HFS_SB(sb)->alloc_blksz = size = be32_to_cpu(mdb->drAlBlkSiz);
> if (!size || (size & (HFS_SECTOR_SIZE - 1))) {
> - printk(KERN_ERR "hfs: bad allocation block size %d\n", size);
> + pr_err("bad allocation block size %d\n", size);
> goto out_bh;
> }
>
> @@ -118,7 +118,7 @@ int hfs_mdb_get(struct super_block *sb)
> size >>= 1;
> brelse(bh);
> if (!sb_set_blocksize(sb, size)) {
> - printk(KERN_ERR "hfs: unable to set blocksize to %u\n", size);
> + pr_err("unable to set blocksize to %u\n", size);
> goto out;
> }
>
> @@ -162,8 +162,8 @@ int hfs_mdb_get(struct super_block *sb)
> }
>
> if (!HFS_SB(sb)->alt_mdb) {
> - printk(KERN_WARNING "hfs: unable to locate alternate MDB\n");
> - printk(KERN_WARNING "hfs: continuing without an alternate MDB\n");
> + pr_warn("unable to locate alternate MDB\n");
> + pr_warn("continuing without an alternate MDB\n");
> }
>
> HFS_SB(sb)->bitmap = (__be32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0);
> @@ -178,7 +178,7 @@ int hfs_mdb_get(struct super_block *sb)
> while (size) {
> bh = sb_bread(sb, off >> sb->s_blocksize_bits);
> if (!bh) {
> - printk(KERN_ERR "hfs: unable to read volume bitmap\n");
> + pr_err("unable to read volume bitmap\n");
> goto out;
> }
> off2 = off & (sb->s_blocksize - 1);
> @@ -192,23 +192,22 @@ int hfs_mdb_get(struct super_block *sb)
>
> HFS_SB(sb)->ext_tree = hfs_btree_open(sb, HFS_EXT_CNID, hfs_ext_keycmp);
> if (!HFS_SB(sb)->ext_tree) {
> - printk(KERN_ERR "hfs: unable to open extent tree\n");
> + pr_err("unable to open extent tree\n");
> goto out;
> }
> HFS_SB(sb)->cat_tree = hfs_btree_open(sb, HFS_CAT_CNID, hfs_cat_keycmp);
> if (!HFS_SB(sb)->cat_tree) {
> - printk(KERN_ERR "hfs: unable to open catalog tree\n");
> + pr_err("unable to open catalog tree\n");
> goto out;
> }
>
> attrib = mdb->drAtrb;
> if (!(attrib & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
> - printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
> - "running fsck.hfs is recommended. mounting read-only.\n");
> + pr_warn("filesystem was not cleanly unmounted, running fsck.hfs is recommended. mounting read-only.\n");
> sb->s_flags |= MS_RDONLY;
> }
> if ((attrib & cpu_to_be16(HFS_SB_ATTRIB_SLOCK))) {
> - printk(KERN_WARNING "hfs: filesystem is marked locked, mounting read-only.\n");
> + pr_warn("filesystem is marked locked, mounting read-only.\n");
> sb->s_flags |= MS_RDONLY;
> }
> if (!(sb->s_flags & MS_RDONLY)) {
> @@ -312,7 +311,7 @@ void hfs_mdb_commit(struct super_block *sb)
> while (size) {
> bh = sb_bread(sb, block);
> if (!bh) {
> - printk(KERN_ERR "hfs: unable to read volume bitmap\n");
> + pr_err("unable to read volume bitmap\n");
> break;
> }
> len = min((int)sb->s_blocksize - off, size);
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index bbaaa8a..3420756 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -117,12 +117,11 @@ static int hfs_remount(struct super_block *sb, int *flags, char *data)
> return 0;
> if (!(*flags & MS_RDONLY)) {
> if (!(HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
> - printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
> - "running fsck.hfs is recommended. leaving read-only.\n");
> + pr_warn("filesystem was not cleanly unmounted, running fsck.hfs is recommended. leaving read-only.\n");
> sb->s_flags |= MS_RDONLY;
> *flags |= MS_RDONLY;
> } else if (HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_SLOCK)) {
> - printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
> + pr_warn("filesystem is marked locked, leaving read-only.\n");
> sb->s_flags |= MS_RDONLY;
> *flags |= MS_RDONLY;
> }
> @@ -253,29 +252,29 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> switch (token) {
> case opt_uid:
> if (match_int(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: uid requires an argument\n");
> + pr_err("uid requires an argument\n");
> return 0;
> }
> hsb->s_uid = make_kuid(current_user_ns(), (uid_t)tmp);
> if (!uid_valid(hsb->s_uid)) {
> - printk(KERN_ERR "hfs: invalid uid %d\n", tmp);
> + pr_err("invalid uid %d\n", tmp);
> return 0;
> }
> break;
> case opt_gid:
> if (match_int(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: gid requires an argument\n");
> + pr_err("gid requires an argument\n");
> return 0;
> }
> hsb->s_gid = make_kgid(current_user_ns(), (gid_t)tmp);
> if (!gid_valid(hsb->s_gid)) {
> - printk(KERN_ERR "hfs: invalid gid %d\n", tmp);
> + pr_err("invalid gid %d\n", tmp);
> return 0;
> }
> break;
> case opt_umask:
> if (match_octal(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: umask requires a value\n");
> + pr_err("umask requires a value\n");
> return 0;
> }
> hsb->s_file_umask = (umode_t)tmp;
> @@ -283,39 +282,39 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> break;
> case opt_file_umask:
> if (match_octal(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: file_umask requires a value\n");
> + pr_err("file_umask requires a value\n");
> return 0;
> }
> hsb->s_file_umask = (umode_t)tmp;
> break;
> case opt_dir_umask:
> if (match_octal(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: dir_umask requires a value\n");
> + pr_err("dir_umask requires a value\n");
> return 0;
> }
> hsb->s_dir_umask = (umode_t)tmp;
> break;
> case opt_part:
> if (match_int(&args[0], &hsb->part)) {
> - printk(KERN_ERR "hfs: part requires an argument\n");
> + pr_err("part requires an argument\n");
> return 0;
> }
> break;
> case opt_session:
> if (match_int(&args[0], &hsb->session)) {
> - printk(KERN_ERR "hfs: session requires an argument\n");
> + pr_err("session requires an argument\n");
> return 0;
> }
> break;
> case opt_type:
> if (match_fourchar(&args[0], &hsb->s_type)) {
> - printk(KERN_ERR "hfs: type requires a 4 character value\n");
> + pr_err("type requires a 4 character value\n");
> return 0;
> }
> break;
> case opt_creator:
> if (match_fourchar(&args[0], &hsb->s_creator)) {
> - printk(KERN_ERR "hfs: creator requires a 4 character value\n");
> + pr_err("creator requires a 4 character value\n");
> return 0;
> }
> break;
> @@ -324,14 +323,14 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> break;
> case opt_codepage:
> if (hsb->nls_disk) {
> - printk(KERN_ERR "hfs: unable to change codepage\n");
> + pr_err("unable to change codepage\n");
> return 0;
> }
> p = match_strdup(&args[0]);
> if (p)
> hsb->nls_disk = load_nls(p);
> if (!hsb->nls_disk) {
> - printk(KERN_ERR "hfs: unable to load codepage \"%s\"\n", p);
> + pr_err("unable to load codepage \"%s\"\n", p);
> kfree(p);
> return 0;
> }
> @@ -339,14 +338,14 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> break;
> case opt_iocharset:
> if (hsb->nls_io) {
> - printk(KERN_ERR "hfs: unable to change iocharset\n");
> + pr_err("unable to change iocharset\n");
> return 0;
> }
> p = match_strdup(&args[0]);
> if (p)
> hsb->nls_io = load_nls(p);
> if (!hsb->nls_io) {
> - printk(KERN_ERR "hfs: unable to load iocharset \"%s\"\n", p);
> + pr_err("unable to load iocharset \"%s\"\n", p);
> kfree(p);
> return 0;
> }
> @@ -360,7 +359,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> if (hsb->nls_disk && !hsb->nls_io) {
> hsb->nls_io = load_nls_default();
> if (!hsb->nls_io) {
> - printk(KERN_ERR "hfs: unable to load default iocharset\n");
> + pr_err("unable to load default iocharset\n");
> return 0;
> }
> }
> @@ -400,7 +399,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
>
> res = -EINVAL;
> if (!parse_options((char *)data, sbi)) {
> - printk(KERN_ERR "hfs: unable to parse mount options.\n");
> + pr_err("unable to parse mount options\n");
> goto bail;
> }
>
> @@ -411,7 +410,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
> res = hfs_mdb_get(sb);
> if (res) {
> if (!silent)
> - printk(KERN_WARNING "hfs: can't find a HFS filesystem on dev %s.\n",
> + pr_warn("can't find a HFS filesystem on dev %s\n",
> hfs_mdb_name(sb));
> res = -EINVAL;
> goto bail;
> @@ -447,7 +446,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
> return 0;
>
> bail_no_root:
> - printk(KERN_ERR "hfs: get root inode failed.\n");
> + pr_err("get root inode failed\n");
> bail:
> hfs_mdb_put(sb);
> return res;
> diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
> index 2043b50..0f47890 100644
> --- a/fs/hfsplus/attributes.c
> +++ b/fs/hfsplus/attributes.c
> @@ -56,7 +56,7 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key,
> if (name) {
> len = strlen(name);
> if (len > HFSPLUS_ATTR_MAX_STRLEN) {
> - printk(KERN_ERR "hfs: invalid xattr name's length\n");
> + pr_err("invalid xattr name's length\n");
> return -EINVAL;
> }
> hfsplus_asc2uni(sb,
> @@ -169,7 +169,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
> hfs_dbg(ATTR_MOD, "find_attr: %s,%d\n", name ? name : NULL, cnid);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> - printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> + pr_err("attributes file doesn't exist\n");
> return -EINVAL;
> }
>
> @@ -232,7 +232,7 @@ int hfsplus_create_attr(struct inode *inode,
> name ? name : NULL, inode->i_ino);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> - printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> + pr_err("attributes file doesn't exist\n");
> return -EINVAL;
> }
>
> @@ -307,10 +307,10 @@ static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
> break;
> case HFSPLUS_ATTR_FORK_DATA:
> case HFSPLUS_ATTR_EXTENTS:
> - printk(KERN_ERR "hfs: only inline data xattr are supported\n");
> + pr_err("only inline data xattr are supported\n");
> return -EOPNOTSUPP;
> default:
> - printk(KERN_ERR "hfs: invalid extended attribute record\n");
> + pr_err("invalid extended attribute record\n");
> return -ENOENT;
> }
>
> @@ -332,7 +332,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
> name ? name : NULL, inode->i_ino);
>
> if (!HFSPLUS_SB(sb)->attr_tree) {
> - printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> + pr_err("attributes file doesn't exist\n");
> return -EINVAL;
> }
>
> @@ -346,7 +346,7 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
> if (err)
> goto out;
> } else {
> - printk(KERN_ERR "hfs: invalid extended attribute name\n");
> + pr_err("invalid extended attribute name\n");
> err = -EINVAL;
> goto out;
> }
> @@ -372,7 +372,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
> hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);
>
> if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
> - printk(KERN_ERR "hfs: attributes file doesn't exist\n");
> + pr_err("attributes file doesn't exist\n");
> return -EINVAL;
> }
>
> @@ -384,7 +384,7 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
> err = hfsplus_find_attr(dir->i_sb, cnid, NULL, &fd);
> if (err) {
> if (err != -ENOENT)
> - printk(KERN_ERR "hfs: xattr search failed.\n");
> + pr_err("xattr search failed\n");
> goto end_delete_all;
> }
>
> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> index d27f37f..c1422d9 100644
> --- a/fs/hfsplus/bfind.c
> +++ b/fs/hfsplus/bfind.c
> @@ -208,7 +208,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
> return res;
>
> invalid:
> - printk(KERN_ERR "hfs: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
> + pr_err("inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
> height, bnode->height, bnode->type, nidx, parent);
> res = -EIO;
> release:
> diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
> index 7da6d46..826e864 100644
> --- a/fs/hfsplus/bitmap.c
> +++ b/fs/hfsplus/bitmap.c
> @@ -238,7 +238,7 @@ out:
> return 0;
>
> kaboom:
> - printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n",
> + pr_crit("hfsplus: unable to mark blocks free: error %ld\n",
> PTR_ERR(page));
> mutex_unlock(&sbi->alloc_mutex);
>
> diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
> index 1ca9304..11c8602 100644
> --- a/fs/hfsplus/bnode.c
> +++ b/fs/hfsplus/bnode.c
> @@ -386,7 +386,7 @@ struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid)
> struct hfs_bnode *node;
>
> if (cnid >= tree->node_count) {
> - printk(KERN_ERR "hfs: request for non-existent node "
> + pr_err("request for non-existent node "
> "%d in B*Tree\n",
> cnid);
> return NULL;
> @@ -409,7 +409,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
> loff_t off;
>
> if (cnid >= tree->node_count) {
> - printk(KERN_ERR "hfs: request for non-existent node "
> + pr_err("request for non-existent node "
> "%d in B*Tree\n",
> cnid);
> return NULL;
> @@ -588,7 +588,7 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num)
> node = hfs_bnode_findhash(tree, num);
> spin_unlock(&tree->hash_lock);
> if (node) {
> - printk(KERN_CRIT "new node %u already hashed?\n", num);
> + pr_crit("new node %u already hashed?\n", num);
> WARN_ON(1);
> return node;
> }
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index e238ba8..6e560d5 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -45,13 +45,13 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
> if (!recoff)
> return 0;
> if (recoff > node->tree->node_size - 2) {
> - printk(KERN_ERR "hfs: recoff %d too large\n", recoff);
> + pr_err("recoff %d too large\n", recoff);
> return 0;
> }
>
> retval = hfs_bnode_read_u16(node, recoff) + 2;
> if (retval > node->tree->max_key_len + 2) {
> - printk(KERN_ERR "hfs: keylen %d too large\n",
> + pr_err("keylen %d too large\n",
> retval);
> retval = 0;
> }
> diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
> index c2fa4bf..0c6540c 100644
> --- a/fs/hfsplus/btree.c
> +++ b/fs/hfsplus/btree.c
> @@ -40,8 +40,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
> tree->inode = inode;
>
> if (!HFSPLUS_I(tree->inode)->first_blocks) {
> - printk(KERN_ERR
> - "hfs: invalid btree extent records (0 size).\n");
> + pr_err("invalid btree extent records (0 size)\n");
> goto free_inode;
> }
>
> @@ -68,12 +67,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
> switch (id) {
> case HFSPLUS_EXT_CNID:
> if (tree->max_key_len != HFSPLUS_EXT_KEYLEN - sizeof(u16)) {
> - printk(KERN_ERR "hfs: invalid extent max_key_len %d\n",
> + pr_err("invalid extent max_key_len %d\n",
> tree->max_key_len);
> goto fail_page;
> }
> if (tree->attributes & HFS_TREE_VARIDXKEYS) {
> - printk(KERN_ERR "hfs: invalid extent btree flag\n");
> + pr_err("invalid extent btree flag\n");
> goto fail_page;
> }
>
> @@ -81,12 +80,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
> break;
> case HFSPLUS_CAT_CNID:
> if (tree->max_key_len != HFSPLUS_CAT_KEYLEN - sizeof(u16)) {
> - printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n",
> + pr_err("invalid catalog max_key_len %d\n",
> tree->max_key_len);
> goto fail_page;
> }
> if (!(tree->attributes & HFS_TREE_VARIDXKEYS)) {
> - printk(KERN_ERR "hfs: invalid catalog btree flag\n");
> + pr_err("invalid catalog btree flag\n");
> goto fail_page;
> }
>
> @@ -100,19 +99,19 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
> break;
> case HFSPLUS_ATTR_CNID:
> if (tree->max_key_len != HFSPLUS_ATTR_KEYLEN - sizeof(u16)) {
> - printk(KERN_ERR "hfs: invalid attributes max_key_len %d\n",
> + pr_err("invalid attributes max_key_len %d\n",
> tree->max_key_len);
> goto fail_page;
> }
> tree->keycmp = hfsplus_attr_bin_cmp_key;
> break;
> default:
> - printk(KERN_ERR "hfs: unknown B*Tree requested\n");
> + pr_err("unknown B*Tree requested\n");
> goto fail_page;
> }
>
> if (!(tree->attributes & HFS_TREE_BIGKEYS)) {
> - printk(KERN_ERR "hfs: invalid btree flag\n");
> + pr_err("invalid btree flag\n");
> goto fail_page;
> }
>
> @@ -155,7 +154,7 @@ void hfs_btree_close(struct hfs_btree *tree)
> while ((node = tree->node_hash[i])) {
> tree->node_hash[i] = node->next_hash;
> if (atomic_read(&node->refcnt))
> - printk(KERN_CRIT "hfs: node %d:%d "
> + pr_crit("node %d:%d "
> "still has %d user(s)!\n",
> node->tree->cnid, node->this,
> atomic_read(&node->refcnt));
> @@ -345,7 +344,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
> hfs_bnode_put(node);
> if (!i) {
> /* panic */;
> - printk(KERN_CRIT "hfs: unable to free bnode %u. "
> + pr_crit("unable to free bnode %u. "
> "bmap not found!\n",
> node->this);
> return;
> @@ -355,7 +354,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
> return;
> if (node->type != HFS_NODE_MAP) {
> /* panic */;
> - printk(KERN_CRIT "hfs: invalid bmap found! "
> + pr_crit("invalid bmap found! "
> "(%u,%d)\n",
> node->this, node->type);
> hfs_bnode_put(node);
> @@ -370,7 +369,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
> m = 1 << (~nidx & 7);
> byte = data[off];
> if (!(byte & m)) {
> - printk(KERN_CRIT "hfs: trying to free free bnode "
> + pr_crit("trying to free free bnode "
> "%u(%d)\n",
> node->this, node->type);
> kunmap(page);
> diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
> index 12cea23..968ce41 100644
> --- a/fs/hfsplus/catalog.c
> +++ b/fs/hfsplus/catalog.c
> @@ -188,12 +188,12 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
>
> type = be16_to_cpu(tmp.type);
> if (type != HFSPLUS_FOLDER_THREAD && type != HFSPLUS_FILE_THREAD) {
> - printk(KERN_ERR "hfs: found bad thread record in catalog\n");
> + pr_err("found bad thread record in catalog\n");
> return -EIO;
> }
>
> if (be16_to_cpu(tmp.thread.nodeName.length) > 255) {
> - printk(KERN_ERR "hfs: catalog name length corrupted\n");
> + pr_err("catalog name length corrupted\n");
> return -EIO;
> }
>
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 031c24e..a37ac93 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -103,7 +103,7 @@ again:
> } else if (!dentry->d_fsdata)
> dentry->d_fsdata = (void *)(unsigned long)cnid;
> } else {
> - printk(KERN_ERR "hfs: invalid catalog entry type in lookup\n");
> + pr_err("invalid catalog entry type in lookup\n");
> err = -EIO;
> goto fail;
> }
> @@ -159,12 +159,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
> hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
> fd.entrylength);
> if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
> - printk(KERN_ERR "hfs: bad catalog folder thread\n");
> + pr_err("bad catalog folder thread\n");
> err = -EIO;
> goto out;
> }
> if (fd.entrylength < HFSPLUS_MIN_THREAD_SZ) {
> - printk(KERN_ERR "hfs: truncated catalog thread\n");
> + pr_err("truncated catalog thread\n");
> err = -EIO;
> goto out;
> }
> @@ -183,7 +183,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>
> for (;;) {
> if (be32_to_cpu(fd.key->cat.parent) != inode->i_ino) {
> - printk(KERN_ERR "hfs: walked past end of dir\n");
> + pr_err("walked past end of dir\n");
> err = -EIO;
> goto out;
> }
> @@ -203,7 +203,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
> if (type == HFSPLUS_FOLDER) {
> if (fd.entrylength <
> sizeof(struct hfsplus_cat_folder)) {
> - printk(KERN_ERR "hfs: small dir entry\n");
> + pr_err("small dir entry\n");
> err = -EIO;
> goto out;
> }
> @@ -216,7 +216,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
> break;
> } else if (type == HFSPLUS_FILE) {
> if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
> - printk(KERN_ERR "hfs: small file entry\n");
> + pr_err("small file entry\n");
> err = -EIO;
> goto out;
> }
> @@ -224,7 +224,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
> be32_to_cpu(entry.file.id), DT_REG))
> break;
> } else {
> - printk(KERN_ERR "hfs: bad catalog entry type\n");
> + pr_err("bad catalog entry type\n");
> err = -EIO;
> goto out;
> }
> diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
> index 7541731..e38f1fa 100644
> --- a/fs/hfsplus/extents.c
> +++ b/fs/hfsplus/extents.c
> @@ -349,7 +349,7 @@ found:
> if (count <= block_nr) {
> err = hfsplus_block_free(sb, start, count);
> if (err) {
> - printk(KERN_ERR "hfs: can't free extent\n");
> + pr_err("can't free extent\n");
> hfs_dbg(EXTENT, " start: %u count: %u\n",
> start, count);
> }
> @@ -360,7 +360,7 @@ found:
> count -= block_nr;
> err = hfsplus_block_free(sb, start + count, block_nr);
> if (err) {
> - printk(KERN_ERR "hfs: can't free extent\n");
> + pr_err("can't free extent\n");
> hfs_dbg(EXTENT, " start: %u count: %u\n",
> start, count);
> }
> @@ -433,7 +433,7 @@ int hfsplus_file_extend(struct inode *inode)
> if (sbi->alloc_file->i_size * 8 <
> sbi->total_blocks - sbi->free_blocks + 8) {
> /* extend alloc file */
> - printk(KERN_ERR "hfs: extend alloc file! "
> + pr_err("extend alloc file! "
> "(%llu,%u,%u)\n",
> sbi->alloc_file->i_size * 8,
> sbi->total_blocks, sbi->free_blocks);
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 910ea98e..60b0a33 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -10,6 +10,12 @@
> #ifndef _LINUX_HFSPLUS_FS_H
> #define _LINUX_HFSPLUS_FS_H
>
> +#ifdef pr_fmt
> +#undef pr_fmt
> +#endif
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/fs.h>
> #include <linux/mutex.h>
> #include <linux/buffer_head.h>
> @@ -32,16 +38,16 @@
> #endif
> #define DBG_MASK (0)
>
> -#define hfs_dbg(flg, fmt, ...) \
> -do { \
> - if (DBG_##flg & DBG_MASK) \
> - printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
> +#define hfs_dbg(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
> } while (0)
>
> -#define hfs_dbg_cont(flg, fmt, ...) \
> -do { \
> - if (DBG_##flg & DBG_MASK) \
> - printk(KERN_CONT fmt, ##__VA_ARGS__); \
> +#define hfs_dbg_cont(flg, fmt, ...) \
> +do { \
> + if (DBG_##flg & DBG_MASK) \
> + pr_cont(fmt, ##__VA_ARGS__); \
> } while (0)
>
> /* Runtime config options */
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index cdd181d..f833d35 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -358,7 +358,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
> if (!error)
> error = error2;
> } else {
> - printk(KERN_ERR "hfs: sync non-existent attributes tree\n");
> + pr_err("sync non-existent attributes tree\n");
> }
> }
>
> @@ -574,7 +574,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
> inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
> HFSPLUS_I(inode)->create_date = file->create_date;
> } else {
> - printk(KERN_ERR "hfs: bad catalog entry used to create inode\n");
> + pr_err("bad catalog entry used to create inode\n");
> res = -EIO;
> }
> return res;
> diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
> index ed257c6..968eab5 100644
> --- a/fs/hfsplus/options.c
> +++ b/fs/hfsplus/options.c
> @@ -113,67 +113,67 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
> switch (token) {
> case opt_creator:
> if (match_fourchar(&args[0], &sbi->creator)) {
> - printk(KERN_ERR "hfs: creator requires a 4 character value\n");
> + pr_err("creator requires a 4 character value\n");
> return 0;
> }
> break;
> case opt_type:
> if (match_fourchar(&args[0], &sbi->type)) {
> - printk(KERN_ERR "hfs: type requires a 4 character value\n");
> + pr_err("type requires a 4 character value\n");
> return 0;
> }
> break;
> case opt_umask:
> if (match_octal(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: umask requires a value\n");
> + pr_err("umask requires a value\n");
> return 0;
> }
> sbi->umask = (umode_t)tmp;
> break;
> case opt_uid:
> if (match_int(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: uid requires an argument\n");
> + pr_err("uid requires an argument\n");
> return 0;
> }
> sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
> if (!uid_valid(sbi->uid)) {
> - printk(KERN_ERR "hfs: invalid uid specified\n");
> + pr_err("invalid uid specified\n");
> return 0;
> }
> break;
> case opt_gid:
> if (match_int(&args[0], &tmp)) {
> - printk(KERN_ERR "hfs: gid requires an argument\n");
> + pr_err("gid requires an argument\n");
> return 0;
> }
> sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
> if (!gid_valid(sbi->gid)) {
> - printk(KERN_ERR "hfs: invalid gid specified\n");
> + pr_err("invalid gid specified\n");
> return 0;
> }
> break;
> case opt_part:
> if (match_int(&args[0], &sbi->part)) {
> - printk(KERN_ERR "hfs: part requires an argument\n");
> + pr_err("part requires an argument\n");
> return 0;
> }
> break;
> case opt_session:
> if (match_int(&args[0], &sbi->session)) {
> - printk(KERN_ERR "hfs: session requires an argument\n");
> + pr_err("session requires an argument\n");
> return 0;
> }
> break;
> case opt_nls:
> if (sbi->nls) {
> - printk(KERN_ERR "hfs: unable to change nls mapping\n");
> + pr_err("unable to change nls mapping\n");
> return 0;
> }
> p = match_strdup(&args[0]);
> if (p)
> sbi->nls = load_nls(p);
> if (!sbi->nls) {
> - printk(KERN_ERR "hfs: unable to load "
> + pr_err("unable to load "
> "nls mapping \"%s\"\n",
> p);
> kfree(p);
> diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
> index 4886fd3..4c4d142 100644
> --- a/fs/hfsplus/super.c
> +++ b/fs/hfsplus/super.c
> @@ -132,7 +132,7 @@ static int hfsplus_system_write_inode(struct inode *inode)
> if (tree) {
> int err = hfs_btree_write(tree);
> if (err) {
> - printk(KERN_ERR "hfs: b-tree write err: %d, ino %lu\n",
> + pr_err("b-tree write err: %d, ino %lu\n",
> err, inode->i_ino);
> return err;
> }
> @@ -251,7 +251,7 @@ static void delayed_sync_fs(struct work_struct *work)
>
> err = hfsplus_sync_fs(sbi->alloc_file->i_sb, 1);
> if (err)
> - printk(KERN_ERR "hfs: delayed sync fs err %d\n", err);
> + pr_err("delayed sync fs err %d\n", err);
> }
>
> void hfsplus_mark_mdb_dirty(struct super_block *sb)
> @@ -333,25 +333,19 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
> return -EINVAL;
>
> if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
> - printk(KERN_WARNING "hfs: filesystem was "
> - "not cleanly unmounted, "
> - "running fsck.hfsplus is recommended. "
> - "leaving read-only.\n");
> + pr_warn("filesystem was not cleanly unmounted, running fsck.hfsplus is recommended. leaving read-only.\n");
> sb->s_flags |= MS_RDONLY;
> *flags |= MS_RDONLY;
> } else if (force) {
> /* nothing */
> } else if (vhdr->attributes &
> cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
> - printk(KERN_WARNING "hfs: filesystem is marked locked, "
> - "leaving read-only.\n");
> + pr_warn("filesystem is marked locked, leaving read-only.\n");
> sb->s_flags |= MS_RDONLY;
> *flags |= MS_RDONLY;
> } else if (vhdr->attributes &
> cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
> - printk(KERN_WARNING "hfs: filesystem is "
> - "marked journaled, "
> - "leaving read-only.\n");
> + pr_warn("filesystem is marked journaled, leaving read-only.\n");
> sb->s_flags |= MS_RDONLY;
> *flags |= MS_RDONLY;
> }
> @@ -397,7 +391,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
>
> err = -EINVAL;
> if (!hfsplus_parse_options(data, sbi)) {
> - printk(KERN_ERR "hfs: unable to parse mount options\n");
> + pr_err("unable to parse mount options\n");
> goto out_unload_nls;
> }
>
> @@ -405,14 +399,14 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> nls = sbi->nls;
> sbi->nls = load_nls("utf8");
> if (!sbi->nls) {
> - printk(KERN_ERR "hfs: unable to load nls for utf8\n");
> + pr_err("unable to load nls for utf8\n");
> goto out_unload_nls;
> }
>
> /* Grab the volume header */
> if (hfsplus_read_wrapper(sb)) {
> if (!silent)
> - printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n");
> + pr_warn("unable to find HFS+ superblock\n");
> goto out_unload_nls;
> }
> vhdr = sbi->s_vhdr;
> @@ -421,7 +415,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> sb->s_magic = HFSPLUS_VOLHEAD_SIG;
> if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION ||
> be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) {
> - printk(KERN_ERR "hfs: wrong filesystem version\n");
> + pr_err("wrong filesystem version\n");
> goto out_free_vhdr;
> }
> sbi->total_blocks = be32_to_cpu(vhdr->total_blocks);
> @@ -445,7 +439,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
>
> if ((last_fs_block > (sector_t)(~0ULL) >> (sbi->alloc_blksz_shift - 9)) ||
> (last_fs_page > (pgoff_t)(~0ULL))) {
> - printk(KERN_ERR "hfs: filesystem size too large.\n");
> + pr_err("filesystem size too large\n");
> goto out_free_vhdr;
> }
>
> @@ -454,22 +448,16 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> sb->s_maxbytes = MAX_LFS_FILESIZE;
>
> if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
> - printk(KERN_WARNING "hfs: Filesystem was "
> - "not cleanly unmounted, "
> - "running fsck.hfsplus is recommended. "
> - "mounting read-only.\n");
> + pr_warn("Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended. mounting read-only.\n");
> sb->s_flags |= MS_RDONLY;
> } else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) {
> /* nothing */
> } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
> - printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
> + pr_warn("Filesystem is marked locked, mounting read-only.\n");
> sb->s_flags |= MS_RDONLY;
> } else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) &&
> !(sb->s_flags & MS_RDONLY)) {
> - printk(KERN_WARNING "hfs: write access to "
> - "a journaled filesystem is not supported, "
> - "use the force option at your own risk, "
> - "mounting read-only.\n");
> + pr_warn("write access to a journaled filesystem is not supported, use the force option at your own risk, mounting read-only.\n");
> sb->s_flags |= MS_RDONLY;
> }
>
> @@ -478,18 +466,18 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> /* Load metadata objects (B*Trees) */
> sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
> if (!sbi->ext_tree) {
> - printk(KERN_ERR "hfs: failed to load extents file\n");
> + pr_err("failed to load extents file\n");
> goto out_free_vhdr;
> }
> sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
> if (!sbi->cat_tree) {
> - printk(KERN_ERR "hfs: failed to load catalog file\n");
> + pr_err("failed to load catalog file\n");
> goto out_close_ext_tree;
> }
> if (vhdr->attr_file.total_blocks != 0) {
> sbi->attr_tree = hfs_btree_open(sb, HFSPLUS_ATTR_CNID);
> if (!sbi->attr_tree) {
> - printk(KERN_ERR "hfs: failed to load attributes file\n");
> + pr_err("failed to load attributes file\n");
> goto out_close_cat_tree;
> }
> }
> @@ -497,7 +485,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
>
> inode = hfsplus_iget(sb, HFSPLUS_ALLOC_CNID);
> if (IS_ERR(inode)) {
> - printk(KERN_ERR "hfs: failed to load allocation file\n");
> + pr_err("failed to load allocation file\n");
> err = PTR_ERR(inode);
> goto out_close_attr_tree;
> }
> @@ -506,7 +494,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
> /* Load the root directory */
> root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID);
> if (IS_ERR(root)) {
> - printk(KERN_ERR "hfs: failed to load root directory\n");
> + pr_err("failed to load root directory\n");
> err = PTR_ERR(root);
> goto out_put_alloc_file;
> }
> diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
> index 2e7ffba..96375a5 100644
> --- a/fs/hfsplus/wrapper.c
> +++ b/fs/hfsplus/wrapper.c
> @@ -157,7 +157,7 @@ static int hfsplus_get_last_session(struct super_block *sb,
> *start = (sector_t)te.cdte_addr.lba << 2;
> return 0;
> }
> - printk(KERN_ERR "hfs: invalid session number or type of track\n");
> + pr_err("invalid session number or type of track\n");
> return -EINVAL;
> }
> ms_info.addr_format = CDROM_LBA;
> @@ -235,8 +235,7 @@ reread:
>
> error = -EINVAL;
> if (sbi->s_backup_vhdr->signature != sbi->s_vhdr->signature) {
> - printk(KERN_WARNING
> - "hfs: invalid secondary volume header\n");
> + pr_warn("invalid secondary volume header\n");
> goto out_free_backup_vhdr;
> }
>
> @@ -260,8 +259,7 @@ reread:
> blocksize >>= 1;
>
> if (sb_set_blocksize(sb, blocksize) != blocksize) {
> - printk(KERN_ERR "hfs: unable to set blocksize to %u!\n",
> - blocksize);
> + pr_err("unable to set blocksize to %u!\n", blocksize);
> goto out_free_backup_vhdr;
> }
>
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index e8a4b08..f663461 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -107,19 +107,19 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
>
> err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
> if (err) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> return err;
> }
>
> err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
> if (err) {
> - printk(KERN_ERR "hfs: catalog searching failed\n");
> + pr_err("catalog searching failed\n");
> goto end_setxattr;
> }
>
> if (!strcmp_xattr_finder_info(name)) {
> if (flags & XATTR_CREATE) {
> - printk(KERN_ERR "hfs: xattr exists yet\n");
> + pr_err("xattr exists yet\n");
> err = -EOPNOTSUPP;
> goto end_setxattr;
> }
> @@ -165,7 +165,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
>
> if (hfsplus_attr_exists(inode, name)) {
> if (flags & XATTR_CREATE) {
> - printk(KERN_ERR "hfs: xattr exists yet\n");
> + pr_err("xattr exists yet\n");
> err = -EOPNOTSUPP;
> goto end_setxattr;
> }
> @@ -177,7 +177,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
> goto end_setxattr;
> } else {
> if (flags & XATTR_REPLACE) {
> - printk(KERN_ERR "hfs: cannot replace xattr\n");
> + pr_err("cannot replace xattr\n");
> err = -EOPNOTSUPP;
> goto end_setxattr;
> }
> @@ -210,7 +210,7 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
> cat_entry_flags);
> hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
> } else {
> - printk(KERN_ERR "hfs: invalid catalog entry type\n");
> + pr_err("invalid catalog entry type\n");
> err = -EIO;
> goto end_setxattr;
> }
> @@ -269,7 +269,7 @@ static ssize_t hfsplus_getxattr_finder_info(struct dentry *dentry,
> if (size >= record_len) {
> res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
> if (res) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> return res;
> }
> res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
> @@ -340,13 +340,13 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
>
> entry = hfsplus_alloc_attr_entry();
> if (!entry) {
> - printk(KERN_ERR "hfs: can't allocate xattr entry\n");
> + pr_err("can't allocate xattr entry\n");
> return -ENOMEM;
> }
>
> res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
> if (res) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> goto failed_getxattr_init;
> }
>
> @@ -355,7 +355,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
> if (res == -ENOENT)
> res = -ENODATA;
> else
> - printk(KERN_ERR "hfs: xattr searching failed\n");
> + pr_err("xattr searching failed\n");
> goto out;
> }
>
> @@ -368,17 +368,17 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
> offsetof(struct hfsplus_attr_inline_data,
> length));
> if (record_length > HFSPLUS_MAX_INLINE_DATA_SIZE) {
> - printk(KERN_ERR "hfs: invalid xattr record size\n");
> + pr_err("invalid xattr record size\n");
> res = -EIO;
> goto out;
> }
> } else if (record_type == HFSPLUS_ATTR_FORK_DATA ||
> record_type == HFSPLUS_ATTR_EXTENTS) {
> - printk(KERN_ERR "hfs: only inline data xattr are supported\n");
> + pr_err("only inline data xattr are supported\n");
> res = -EOPNOTSUPP;
> goto out;
> } else {
> - printk(KERN_ERR "hfs: invalid xattr record\n");
> + pr_err("invalid xattr record\n");
> res = -EIO;
> goto out;
> }
> @@ -427,7 +427,7 @@ static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry,
>
> res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
> if (res) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> return res;
> }
>
> @@ -506,7 +506,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
>
> err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
> if (err) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> return err;
> }
>
> @@ -525,8 +525,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
> for (;;) {
> key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset);
> if (key_len == 0 || key_len > fd.tree->max_key_len) {
> - printk(KERN_ERR "hfs: invalid xattr key length: %d\n",
> - key_len);
> + pr_err("invalid xattr key length: %d\n", key_len);
> res = -EIO;
> goto end_listxattr;
> }
> @@ -541,7 +540,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
> if (hfsplus_uni2asc(inode->i_sb,
> (const struct hfsplus_unistr *)&fd.key->attr.key_name,
> strbuf, &xattr_name_len)) {
> - printk(KERN_ERR "hfs: unicode conversion failed\n");
> + pr_err("unicode conversion failed\n");
> res = -EIO;
> goto end_listxattr;
> }
> @@ -598,13 +597,13 @@ int hfsplus_removexattr(struct dentry *dentry, const char *name)
>
> err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
> if (err) {
> - printk(KERN_ERR "hfs: can't init xattr find struct\n");
> + pr_err("can't init xattr find struct\n");
> return err;
> }
>
> err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
> if (err) {
> - printk(KERN_ERR "hfs: catalog searching failed\n");
> + pr_err("catalog searching failed\n");
> goto end_removexattr;
> }
>
> @@ -643,7 +642,7 @@ int hfsplus_removexattr(struct dentry *dentry, const char *name)
> flags);
> hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
> } else {
> - printk(KERN_ERR "hfs: invalid catalog entry type\n");
> + pr_err("invalid catalog entry type\n");
> err = -EIO;
> goto end_removexattr;
> }

2013-04-09 10:39:48

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 0/2] hfs/hfsplus: Modernize logging styles

On Tue, 2013-04-09 at 11:08 +0400, Vyacheslav Dubeyko wrote:
> On Mon, 2013-04-08 at 09:37 -0700, Joe Perches wrote:
> > Joe Perches (2):
> > hfs/hfsplus: Convert dprint to hfs_dbg
> > hfs/hfsplus: Convert printks to pr_<level>
[]
> But I have some additional suggestions:
> (1) I think that it makes sense to use no_printk() for the case when we
> don't need in debug output.

I don't.

no_printk is used simply to get gcc to verify
format and args with __printf().

The equivalent is already done by the
if (DBG_##FLAG & DBG_MASK)
printk(...)
when DBG_MASK is 0

> (2) I think that it is really necessary to add info about file and line
> number for the case of debug output.

I don't. I think file/line is pretty useless.

Adding dynamic_debug could be useful, but that's
another patch.

Also, checkpatch can be a useful tool, but all
its warnings aren't necessary to always be fixed.

Also, please remember to trim your replies.
It's not necessary to quote the entire email.
Just quote the useful contextual bits.
_Lots_ of people read this list and you can
cause a lot to waste time looking for additional
comments you don't make.

2013-04-09 11:06:29

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 0/2] hfs/hfsplus: Modernize logging styles

On Tue, 2013-04-09 at 03:39 -0700, Joe Perches wrote:
> On Tue, 2013-04-09 at 11:08 +0400, Vyacheslav Dubeyko wrote:
> > On Mon, 2013-04-08 at 09:37 -0700, Joe Perches wrote:
> > > Joe Perches (2):
> > > hfs/hfsplus: Convert dprint to hfs_dbg
> > > hfs/hfsplus: Convert printks to pr_<level>
> []
> > But I have some additional suggestions:
> > (1) I think that it makes sense to use no_printk() for the case when we
> > don't need in debug output.
>
> I don't.
>
> no_printk is used simply to get gcc to verify
> format and args with __printf().
>
> The equivalent is already done by the
> if (DBG_##FLAG & DBG_MASK)
> printk(...)
> when DBG_MASK is 0
>

Ok. I agree.

> > (2) I think that it is really necessary to add info about file and line
> > number for the case of debug output.
>
> I don't. I think file/line is pretty useless.
>

I don't think so. Namely during debugging the file/line info is very
useful, from my point of view. So, I think that this adding makes sense.

> Adding dynamic_debug could be useful, but that's
> another patch.
>
> Also, checkpatch can be a useful tool, but all
> its warnings aren't necessary to always be fixed.
>

As I see, the goal of this patch set is overcome of checkpatch warnings.
I'd prefer not change the style of error messages in HFS/HFS+ drivers.
But this patch set makes sense because it fixes warnings of checkpatch
related to error messages.

Moreover, as I see the most of rest checkpatch's warnings makes sense
and it needs to be fixed, from my point of view.

> Also, please remember to trim your replies.
> It's not necessary to quote the entire email.
> Just quote the useful contextual bits.
> _Lots_ of people read this list and you can
> cause a lot to waste time looking for additional
> comments you don't make.

Sorry. It's my mistake.

With the best regards,
Vyacheslav Dubeyko.

>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2013-04-09 18:14:16

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH 1/2] hfs: add error checking for hfs_find_init()

hfs_find_init() may fail with ENOMEM, but there are places,
where the returned value is not checked. The consequences can be
very unpleasant, e.g. kfree uninitialized pointer and
inappropriate mutex unlocking.

The patch adds checks for errors in hfs_find_init().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
fs/hfs/catalog.c | 12 +++++++++---
fs/hfs/dir.c | 8 ++++++--
fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
fs/hfs/hfs_fs.h | 2 +-
fs/hfs/inode.c | 11 +++++++++--
fs/hfs/super.c | 4 +++-
6 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 424b033..9569b39 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
return -ENOSPC;

sb = dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (err)
+ return err;

hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
@@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)

dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
sb = dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (res)
+ return res;

hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
res = hfs_brec_find(&fd);
@@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
dst_dir->i_ino, dst_name->name);
sb = src_dir->i_sb;
- hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
+ if (err)
+ return err;
dst_fd = src_fd;

/* find the old dir entry and read the data */
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 5f7f1ab..e1c8048 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
struct inode *inode = NULL;
int res;

- hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ if (res)
+ return ERR_PTR(res);
hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
res = hfs_brec_read(&fd, &rec, sizeof(rec));
if (res) {
@@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (filp->f_pos >= inode->i_size)
return 0;

- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (err)
+ return err;
hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
err = hfs_brec_find(&fd);
if (err)
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index a67955a..813447b 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
}

-static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
+static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
{
int res;

@@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
res = hfs_brec_find(fd);
if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
if (res != -ENOENT)
- return;
+ return res;
hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
} else {
if (res)
- return;
+ return res;
hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
}
+ return 0;
}

-void hfs_ext_write_extent(struct inode *inode)
+int hfs_ext_write_extent(struct inode *inode)
{
struct hfs_find_data fd;
+ int res = 0;

if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
- hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
- __hfs_ext_write_extent(inode, &fd);
+ res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+ if (res)
+ return res;
+ res = __hfs_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
+ return res;
}

static inline int __hfs_ext_read_extent(struct hfs_find_data *fd, struct hfs_extent *extent,
@@ -161,8 +166,11 @@ static inline int __hfs_ext_cache_extent(struct hfs_find_data *fd, struct inode
{
int res;

- if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY)
- __hfs_ext_write_extent(inode, fd);
+ if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
+ res = __hfs_ext_write_extent(inode, fd);
+ if (res)
+ return res;
+ }

res = __hfs_ext_read_extent(fd, HFS_I(inode)->cached_extents, inode->i_ino,
block, HFS_IS_RSRC(inode) ? HFS_FK_RSRC : HFS_FK_DATA);
@@ -185,9 +193,11 @@ static int hfs_ext_read_extent(struct inode *inode, u16 block)
block < HFS_I(inode)->cached_start + HFS_I(inode)->cached_blocks)
return 0;

- hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
- res = __hfs_ext_cache_extent(&fd, inode, block);
- hfs_find_exit(&fd);
+ res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+ if (!res) {
+ res = __hfs_ext_cache_extent(&fd, inode, block);
+ hfs_find_exit(&fd);
+ }
return res;
}

@@ -298,7 +308,9 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
if (total_blocks == blocks)
return 0;

- hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ if (res)
+ return res;
do {
res = __hfs_ext_read_extent(&fd, extent, cnid, total_blocks, type);
if (res)
@@ -438,7 +450,9 @@ out:

insert_extent:
dprint(DBG_EXTENT, "insert new extent\n");
- hfs_ext_write_extent(inode);
+ res = hfs_ext_write_extent(inode);
+ if (res)
+ goto out;

memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
HFS_I(inode)->cached_extents[0].block = cpu_to_be16(start);
@@ -466,7 +480,6 @@ void hfs_file_truncate(struct inode *inode)
struct address_space *mapping = inode->i_mapping;
void *fsdata;
struct page *page;
- int res;

/* XXX: Can use generic_cont_expand? */
size = inode->i_size - 1;
@@ -488,7 +501,12 @@ void hfs_file_truncate(struct inode *inode)
goto out;

mutex_lock(&HFS_I(inode)->extents_lock);
- hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
+ if (res) {
+ mutex_unlock(&HFS_I(inode)->extents_lock);
+ /* XXX: We lack error handling of hfs_file_truncate() */
+ return;
+ }
while (1) {
if (alloc_cnt == HFS_I(inode)->first_blocks) {
hfs_free_extents(sb, HFS_I(inode)->first_extents,
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 693df9f..67817af 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -174,7 +174,7 @@ extern const struct inode_operations hfs_dir_inode_operations;
/* extent.c */
extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
-extern void hfs_ext_write_extent(struct inode *);
+extern int hfs_ext_write_extent(struct inode *);
extern int hfs_extend_file(struct inode *);
extern void hfs_file_truncate(struct inode *);

diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 3031dfd..0847471 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -416,9 +416,12 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
struct inode *main_inode = inode;
struct hfs_find_data fd;
hfs_cat_rec rec;
+ int res;

dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
- hfs_ext_write_extent(inode);
+ res = hfs_ext_write_extent(inode);
+ if (res)
+ return res;

if (inode->i_ino < HFS_FIRSTUSER_CNID) {
switch (inode->i_ino) {
@@ -515,7 +518,11 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
if (!inode)
return ERR_PTR(-ENOMEM);

- hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+ if (res) {
+ iput(inode);
+ return ERR_PTR(res);
+ }
fd.search_key->cat = HFS_I(dir)->cat_key;
res = hfs_brec_read(&fd, &rec, sizeof(rec));
if (!res) {
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index bbaaa8a..719760b 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -418,7 +418,9 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
}

/* try to get the root inode */
- hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
+ if (res)
+ goto bail_no_root;
res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
if (!res) {
if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
--
1.7.9.5

2013-04-09 18:14:34

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH 2/2] hfsplus: add error propagation to __hfsplus_ext_write_extent()

__hfsplus_ext_write_extent() suppresses errors coming from hfs_brec_find().
The patch implements error code propagation.

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
fs/hfsplus/extents.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index a94f0f7..fed73f7 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -83,7 +83,7 @@ static u32 hfsplus_ext_lastblock(struct hfsplus_extent *ext)
return be32_to_cpu(ext->start_block) + be32_to_cpu(ext->block_count);
}

-static void __hfsplus_ext_write_extent(struct inode *inode,
+static int __hfsplus_ext_write_extent(struct inode *inode,
struct hfs_find_data *fd)
{
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
@@ -98,13 +98,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
res = hfs_brec_find(fd, hfs_find_rec_by_key);
if (hip->extent_state & HFSPLUS_EXT_NEW) {
if (res != -ENOENT)
- return;
+ return res;
hfs_brec_insert(fd, hip->cached_extents,
sizeof(hfsplus_extent_rec));
hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
} else {
if (res)
- return;
+ return res;
hfs_bnode_write(fd->bnode, hip->cached_extents,
fd->entryoffset, fd->entrylength);
hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
@@ -117,11 +117,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
* to explicily mark the inode dirty, too.
*/
set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
+
+ return 0;
}

static int hfsplus_ext_write_extent_locked(struct inode *inode)
{
- int res;
+ int res = 0;

if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
struct hfs_find_data fd;
@@ -129,10 +131,10 @@ static int hfsplus_ext_write_extent_locked(struct inode *inode)
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
if (res)
return res;
- __hfsplus_ext_write_extent(inode, &fd);
+ res = __hfsplus_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
- return 0;
+ return res;
}

int hfsplus_ext_write_extent(struct inode *inode)
@@ -175,8 +177,11 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd,

WARN_ON(!mutex_is_locked(&hip->extents_lock));

- if (hip->extent_state & HFSPLUS_EXT_DIRTY)
- __hfsplus_ext_write_extent(inode, fd);
+ if (hip->extent_state & HFSPLUS_EXT_DIRTY) {
+ res = __hfsplus_ext_write_extent(inode, fd);
+ if (res)
+ return res;
+ }

res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
block, HFSPLUS_IS_RSRC(inode) ?
--
1.7.9.5

2013-04-10 06:40:28

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs: add error checking for hfs_find_init()

On Tue, 2013-04-09 at 22:14 +0400, Alexey Khoroshilov wrote:
> hfs_find_init() may fail with ENOMEM, but there are places,
> where the returned value is not checked. The consequences can be
> very unpleasant, e.g. kfree uninitialized pointer and
> inappropriate mutex unlocking.
>
> The patch adds checks for errors in hfs_find_init().
>

Looks good for me.

Reviewed-by: Vyacheslav Dubeyko <[email protected]>

Tnanks,
Vyacheslav Dubeyko.

> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---
> fs/hfs/catalog.c | 12 +++++++++---
> fs/hfs/dir.c | 8 ++++++--
> fs/hfs/extent.c | 48 +++++++++++++++++++++++++++++++++---------------
> fs/hfs/hfs_fs.h | 2 +-
> fs/hfs/inode.c | 11 +++++++++--
> fs/hfs/super.c | 4 +++-
> 6 files changed, 61 insertions(+), 24 deletions(-)
>
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index 424b033..9569b39 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
> return -ENOSPC;
>
> sb = dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (err)
> + return err;
>
> hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
> entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
> @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
>
> dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
> sb = dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (res)
> + return res;
>
> hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
> res = hfs_brec_find(&fd);
> @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
> dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
> dst_dir->i_ino, dst_name->name);
> sb = src_dir->i_sb;
> - hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
> + if (err)
> + return err;
> dst_fd = src_fd;
>
> /* find the old dir entry and read the data */
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 5f7f1ab..e1c8048 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
> struct inode *inode = NULL;
> int res;
>
> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + if (res)
> + return ERR_PTR(res);
> hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
> res = hfs_brec_read(&fd, &rec, sizeof(rec));
> if (res) {
> @@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
> if (filp->f_pos >= inode->i_size)
> return 0;
>
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (err)
> + return err;
> hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
> err = hfs_brec_find(&fd);
> if (err)
> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
> index a67955a..813447b 100644
> --- a/fs/hfs/extent.c
> +++ b/fs/hfs/extent.c
> @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
> return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
> }
>
> -static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
> +static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
> {
> int res;
>
> @@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
> res = hfs_brec_find(fd);
> if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
> if (res != -ENOENT)
> - return;
> + return res;
> hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
> HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
> } else {
> if (res)
> - return;
> + return res;
> hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
> HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
> }
> + return 0;
> }
>
> -void hfs_ext_write_extent(struct inode *inode)
> +int hfs_ext_write_extent(struct inode *inode)
> {
> struct hfs_find_data fd;
> + int res = 0;
>
> if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
> - hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> - __hfs_ext_write_extent(inode, &fd);
> + res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> + if (res)
> + return res;
> + res = __hfs_ext_write_extent(inode, &fd);
> hfs_find_exit(&fd);
> }
> + return res;
> }
>
> static inline int __hfs_ext_read_extent(struct hfs_find_data *fd, struct hfs_extent *extent,
> @@ -161,8 +166,11 @@ static inline int __hfs_ext_cache_extent(struct hfs_find_data *fd, struct inode
> {
> int res;
>
> - if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY)
> - __hfs_ext_write_extent(inode, fd);
> + if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
> + res = __hfs_ext_write_extent(inode, fd);
> + if (res)
> + return res;
> + }
>
> res = __hfs_ext_read_extent(fd, HFS_I(inode)->cached_extents, inode->i_ino,
> block, HFS_IS_RSRC(inode) ? HFS_FK_RSRC : HFS_FK_DATA);
> @@ -185,9 +193,11 @@ static int hfs_ext_read_extent(struct inode *inode, u16 block)
> block < HFS_I(inode)->cached_start + HFS_I(inode)->cached_blocks)
> return 0;
>
> - hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> - res = __hfs_ext_cache_extent(&fd, inode, block);
> - hfs_find_exit(&fd);
> + res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
> + if (!res) {
> + res = __hfs_ext_cache_extent(&fd, inode, block);
> + hfs_find_exit(&fd);
> + }
> return res;
> }
>
> @@ -298,7 +308,9 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
> if (total_blocks == blocks)
> return 0;
>
> - hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + if (res)
> + return res;
> do {
> res = __hfs_ext_read_extent(&fd, extent, cnid, total_blocks, type);
> if (res)
> @@ -438,7 +450,9 @@ out:
>
> insert_extent:
> dprint(DBG_EXTENT, "insert new extent\n");
> - hfs_ext_write_extent(inode);
> + res = hfs_ext_write_extent(inode);
> + if (res)
> + goto out;
>
> memset(HFS_I(inode)->cached_extents, 0, sizeof(hfs_extent_rec));
> HFS_I(inode)->cached_extents[0].block = cpu_to_be16(start);
> @@ -466,7 +480,6 @@ void hfs_file_truncate(struct inode *inode)
> struct address_space *mapping = inode->i_mapping;
> void *fsdata;
> struct page *page;
> - int res;
>
> /* XXX: Can use generic_cont_expand? */
> size = inode->i_size - 1;
> @@ -488,7 +501,12 @@ void hfs_file_truncate(struct inode *inode)
> goto out;
>
> mutex_lock(&HFS_I(inode)->extents_lock);
> - hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
> + if (res) {
> + mutex_unlock(&HFS_I(inode)->extents_lock);
> + /* XXX: We lack error handling of hfs_file_truncate() */
> + return;
> + }
> while (1) {
> if (alloc_cnt == HFS_I(inode)->first_blocks) {
> hfs_free_extents(sb, HFS_I(inode)->first_extents,
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index 693df9f..67817af 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -174,7 +174,7 @@ extern const struct inode_operations hfs_dir_inode_operations;
> /* extent.c */
> extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
> extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
> -extern void hfs_ext_write_extent(struct inode *);
> +extern int hfs_ext_write_extent(struct inode *);
> extern int hfs_extend_file(struct inode *);
> extern void hfs_file_truncate(struct inode *);
>
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 3031dfd..0847471 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -416,9 +416,12 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
> struct inode *main_inode = inode;
> struct hfs_find_data fd;
> hfs_cat_rec rec;
> + int res;
>
> dprint(DBG_INODE, "hfs_write_inode: %lu\n", inode->i_ino);
> - hfs_ext_write_extent(inode);
> + res = hfs_ext_write_extent(inode);
> + if (res)
> + return res;
>
> if (inode->i_ino < HFS_FIRSTUSER_CNID) {
> switch (inode->i_ino) {
> @@ -515,7 +518,11 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
> if (!inode)
> return ERR_PTR(-ENOMEM);
>
> - hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
> + if (res) {
> + iput(inode);
> + return ERR_PTR(res);
> + }
> fd.search_key->cat = HFS_I(dir)->cat_key;
> res = hfs_brec_read(&fd, &rec, sizeof(rec));
> if (!res) {
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index bbaaa8a..719760b 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -418,7 +418,9 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
> }
>
> /* try to get the root inode */
> - hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
> + if (res)
> + goto bail_no_root;
> res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
> if (!res) {
> if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {

2013-04-10 06:40:51

by Vyacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 2/2] hfsplus: add error propagation to __hfsplus_ext_write_extent()

On Tue, 2013-04-09 at 22:14 +0400, Alexey Khoroshilov wrote:
> __hfsplus_ext_write_extent() suppresses errors coming from hfs_brec_find().
> The patch implements error code propagation.
>

Looks good for me.

Reviewed-by: Vyacheslav Dubeyko <[email protected]>

Tnanks,
Vyacheslav Dubeyko.

> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---
> fs/hfsplus/extents.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
> index a94f0f7..fed73f7 100644
> --- a/fs/hfsplus/extents.c
> +++ b/fs/hfsplus/extents.c
> @@ -83,7 +83,7 @@ static u32 hfsplus_ext_lastblock(struct hfsplus_extent *ext)
> return be32_to_cpu(ext->start_block) + be32_to_cpu(ext->block_count);
> }
>
> -static void __hfsplus_ext_write_extent(struct inode *inode,
> +static int __hfsplus_ext_write_extent(struct inode *inode,
> struct hfs_find_data *fd)
> {
> struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
> @@ -98,13 +98,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
> res = hfs_brec_find(fd, hfs_find_rec_by_key);
> if (hip->extent_state & HFSPLUS_EXT_NEW) {
> if (res != -ENOENT)
> - return;
> + return res;
> hfs_brec_insert(fd, hip->cached_extents,
> sizeof(hfsplus_extent_rec));
> hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
> } else {
> if (res)
> - return;
> + return res;
> hfs_bnode_write(fd->bnode, hip->cached_extents,
> fd->entryoffset, fd->entrylength);
> hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
> @@ -117,11 +117,13 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
> * to explicily mark the inode dirty, too.
> */
> set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
> +
> + return 0;
> }
>
> static int hfsplus_ext_write_extent_locked(struct inode *inode)
> {
> - int res;
> + int res = 0;
>
> if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
> struct hfs_find_data fd;
> @@ -129,10 +131,10 @@ static int hfsplus_ext_write_extent_locked(struct inode *inode)
> res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
> if (res)
> return res;
> - __hfsplus_ext_write_extent(inode, &fd);
> + res = __hfsplus_ext_write_extent(inode, &fd);
> hfs_find_exit(&fd);
> }
> - return 0;
> + return res;
> }
>
> int hfsplus_ext_write_extent(struct inode *inode)
> @@ -175,8 +177,11 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd,
>
> WARN_ON(!mutex_is_locked(&hip->extents_lock));
>
> - if (hip->extent_state & HFSPLUS_EXT_DIRTY)
> - __hfsplus_ext_write_extent(inode, fd);
> + if (hip->extent_state & HFSPLUS_EXT_DIRTY) {
> + res = __hfsplus_ext_write_extent(inode, fd);
> + if (res)
> + return res;
> + }
>
> res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
> block, HFSPLUS_IS_RSRC(inode) ?

2013-04-15 00:59:59

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

--- On Mon, 8/4/13, Joe Perches <[email protected]> wrote:

> Use a more current logging style.
>
> Rename macro and uses.
> Add do {} while (0) to macro.
> Add DBG_ to macro.
> Add and use hfs_dbg_cont variant where appropriate.
>
> Signed-off-by: Joe Perches <[email protected]rches.com>

<a lot of dprint to hfs_dbg changes snipped>

> +++ b/fs/hfs/hfs_fs.h
> @@ -34,8 +34,18 @@
> //#define DBG_MASK???
> (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
> #define DBG_MASK??? (0)
>
> -#define dprint(flg, fmt, args...) \
> -??? if (flg & DBG_MASK) printk(fmt , ##
> args)
> +#define hfs_dbg(flg, fmt, ...)???
> ??? ??? ??? \
> +do {??? ???
> ??? ??? ???
> ??? ??? \
> +??? if (DBG_##flg &
> DBG_MASK)??? ???
> ??? \
> +??? ??? printk(KERN_DEBUG
> fmt, ##__VA_ARGS__);??? \
> +} while (0)
> +
> +#define hfs_dbg_cont(flg, fmt, ...)???
> ??? ??? \
> +do {??? ???
> ??? ??? ???
> ??? ??? \
> +??? if (DBG_##flg &
> DBG_MASK)??? ???
> ??? \
> +??? ??? printk(KERN_CONT fmt,
> ##__VA_ARGS__);??? \
> +} while (0)
> +
>
> /*
> ? * struct hfs_inode_info

<a lot of dprint to hfs_dbg change snipped>

This set of change seems to be somewhat zealous - it doesn't offer any benefits other than possibly satisfying somebody's idea of code-purity.

FWIW, I have been sitting on a patch which changes this part of the code to dynamic debugging, and it is much simplier. Just:

=============================
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index e298b83..55d211d 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -45,8 +25,7 @@
#define HFSPLUS_JOURNAL_SWAP 1

#define dprint(flg, fmt, args...) \
- if (flg & DBG_MASK) \
- printk(fmt , ## args)
+ pr_debug(fmt , ## args)

/* Runtime config options */
#define HFSPLUS_DEF_CR_TYPE 0x3F3F3F3F /* '????' */
=========================

(and you can then remove all the DBG_* defines before that, since they then don't have any effect any more).

The benefit of this alternative is that it does not break any out-of-tree patches, while make it easier to debug say patches... and I am still sitting on a rather substantial set of the journal change, plus all the other issues that come out of it, like the folder count patch for case-sensitive file systems.

I think one needs to think very carefully about make bulk changes like this, which serves no real purpose other than satisfying somebody's idea of code purity.

The problem with such bulk "stylistic" changes, is that it forces people who are working on real functionalities and bug fixes to rebase their work, and spend time on doing so, and also at the risk introducing new bugs while rebasing. I know I am writing on a somewhat selfish purpose: if I need to rebase my work due to other's bug fixes or enhancement, etc, then fair enough, but I'd prefer not to rebase for the purpose of other's preference of, and attempts at re-arranging the style of the debug statements, when the debugging output means little to them.




2013-04-15 01:51:20

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

On Mon, 2013-04-15 at 01:53 +0100, Hin-Tak Leung wrote:
> --- On Mon, 8/4/13, Joe Perches <[email protected]> wrote:
> > Use a more current logging style.
[]
> I have been sitting on a patch which changes this part of the code to dynamic debugging, and it is much simplier. Just:
> #define dprint(flg, fmt, args...) \
> - if (flg & DBG_MASK) \
> - printk(fmt , ## args)
> + pr_debug(fmt , ## args)

This change wouldn't work well as it would make a mess
of output that uses no prefix (ie: emits at KERN_DEFAULT)
with output that uses KERN_DEBUG

That's the reason for _dbg and _dbg_cont.

2013-04-15 01:56:18

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

--- On Mon, 15/4/13, Joe Perches <[email protected]> wrote:

> On Mon, 2013-04-15 at 01:53 +0100,
> Hin-Tak Leung wrote:
> > --- On Mon, 8/4/13, Joe Perches <[email protected]>
> wrote:
> > > Use a more current logging style.
> []
> > I have been sitting on a patch which changes this part
> of the code to dynamic debugging, and it is much simplier.
> Just:
> > #define dprint(flg, fmt, args...) \
> > -? ? ???if (flg &
> DBG_MASK) \
> > -? ? ? ? ? ?
> ???printk(fmt , ## args)
> > +? ? ? ? ? ?
> ???pr_debug(fmt , ## args)
>
> This change wouldn't work well as it would make a mess
> of output that uses no prefix (ie: emits at KERN_DEFAULT)
> with output that uses KERN_DEBUG
>
> That's the reason for _dbg and _dbg_cont.

Hmm, I don't get it. Is there any *existing* use of dprint in the hfplus code which is affected by your comment? Or is this another general stylistic comment? i.e. "this does not work in general"?

2013-04-15 02:06:20

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

On Mon, 2013-04-15 at 02:56 +0100, Hin-Tak Leung wrote:
> --- On Mon, 15/4/13, Joe Perches <[email protected]> wrote:
> > On Mon, 2013-04-15 at 01:53 +0100,
> > Hin-Tak Leung wrote:
> > > --- On Mon, 8/4/13, Joe Perches <[email protected]> wrote:
> > > > Use a more current logging style.
> > []
> > > I have been sitting on a patch which changes this part
> > of the code to dynamic debugging, and it is much simplier.
[]
> > This change wouldn't work well as it would make a mess
> > of output that uses no prefix (ie: emits at KERN_DEFAULT)
> > with output that uses KERN_DEBUG
> >
> > That's the reason for _dbg and _dbg_cont.
>
> Hmm, I don't get it. Is there any *existing* use of dprint
> in the hfplus code which is affected by your comment?

Code like this prints out currently on a single line at
KERN_DEFAULT.

@@ -138,16 +138,16 @@ void hfs_bnode_dump(struct hfs_bnode *node)
[]
for (i = be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
key_off = hfs_bnode_read_u16(node, off);
- dprint(DBG_BNODE_MOD, " %d", key_off);
+ hfs_dbg_cont(BNODE_MOD, " %d", key_off);

By converting this dprint() to pr_debug(), it would
print out on a multiple lines, one for each read.

That's why it should use a mechanism like dbg_cont.

btw: there is no current pr_debug_cont mechanism.

2013-04-15 03:52:15

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

--- On Mon, 15/4/13, Joe Perches <[email protected]> wrote:

> On Mon, 2013-04-15 at 02:56 +0100,
> Hin-Tak Leung wrote:
> > --- On Mon, 15/4/13, Joe Perches <[email protected]>
> wrote:
> > > On Mon, 2013-04-15 at 01:53 +0100,
> > > Hin-Tak Leung wrote:
> > > > --- On Mon, 8/4/13, Joe Perches <[email protected]>
> wrote:
> > > > > Use a more current logging style.
> > > []
> > > > I have been sitting on a patch which changes
> this part
> > > of the code to dynamic debugging, and it is much
> simplier.
> []
> > > This change wouldn't work well as it would make a
> mess
> > > of output that uses no prefix (ie: emits at
> KERN_DEFAULT)
> > > with output that uses KERN_DEBUG
> > >
> > > That's the reason for _dbg and _dbg_cont.
> >
> > Hmm, I don't get it. Is there any *existing* use of
> dprint
> > in the hfplus code which is affected by your comment?
>
> Code like this prints out currently on a single line at
> KERN_DEFAULT.
>
> @@ -138,16 +138,16 @@ void hfs_bnode_dump(struct hfs_bnode
> *node)
> []
> ? ? ? ? for (i =
> be16_to_cpu(desc.num_recs); i >= 0; off -= 2, i--) {
> ? ? ? ? ? ? ? ?
> key_off = hfs_bnode_read_u16(node, off);
> -? ? ? ? ? ?
> ???dprint(DBG_BNODE_MOD, " %d", key_off);
> +? ? ? ? ? ?
> ???hfs_dbg_cont(BNODE_MOD, " %d", key_off);
>
> By converting this dprint() to pr_debug(), it would
> print out on a multiple lines, one for each read.
>
> That's why it should use a mechanism like dbg_cont.
>
> btw: there is no current pr_debug_cont mechanism.

That's rubbish. dprint() are compiled in/out debug printing statements, and are entirely suppressed in unmodified kernel source (the value of DBG_MASK being zero). So your rather large and invasive change - which is still conditional on DBG_MASK - is just substituting one form of print nothing to another form of print nothing.

I am not saying what I have in private is correct - otherwise I would have submitted it a long time ago. What I am saying is that the code snipplet I posted is functional: it is not conditional on DBG_MASK, but conditional on the meaning of pr_debug (and only on it), which is either printing indiscriminantly, or on/off switchable at runtime for dynamically enabled kernel. And it is a small and non-invasive change in any case, which I can hang on to indefinitely.

I think the current *implementation* of dprint is bad - it depending on a modification of kernel source and re-compilation to make debug statement visible instead of the default "print nothing". But your patch, which modifies a lot of "print nothing" to another style of "print nothing", has no functional consequence at all. There is no user-visible change. It changes a few hundred lines of print nothing to another few hundred lines of print nothing.



2013-04-15 04:00:12

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

On Mon, 2013-04-15 at 04:46 +0100, Hin-Tak Leung wrote:
> > By converting this dprint() to pr_debug(), it would
> > print out on a multiple lines, one for each read.
> >
> > That's why it should use a mechanism like dbg_cont.
> >
> > btw: there is no current pr_debug_cont mechanism.
>
> That's rubbish.

Don't be silly.

> dprint() are compiled in/out debug printing statements,
> and are entirely suppressed in unmodified kernel source

Of course.

> I am not saying what I have in private is correct

Then your original post wasn't useful either.

> What I am saying is that the code snipplet I posted is functional:

Lots of code is functional, I prefer functional
and correct though.

cheers, Joe

2013-04-15 04:22:21

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

--- On Mon, 15/4/13, Joe Perches <[email protected]> wrote:

> On Mon, 2013-04-15 at 04:46 +0100,
> Hin-Tak Leung wrote:
> > > By converting this dprint() to pr_debug(), it
> would
> > > print out on a multiple lines, one for each read.
> > >
> > > That's why it should use a mechanism like
> dbg_cont.
> > >
> > > btw: there is no current pr_debug_cont mechanism.
> >
> > That's rubbish.
>
> Don't be silly.
>
> > dprint() are compiled in/out debug printing
> statements,
> > and are entirely suppressed in unmodified kernel
> source
>
> Of course.
>
> > I am not saying what I have in private is correct
>
> Then your original post wasn't useful either.
>
> > What I am saying is that the code snipplet I posted is
> functional:
>
> Lots of code is functional, I prefer functional
> and correct though.
>
> cheers, Joe

Hmm, you obvious has a different meaning of "functional" than I. How is converting a few hundred lines of "print nothing" to another few hundred lines of "print nothing" functional? What does it achieve?

I have already voiced my (admittedly selfish) concern: changing a few hundred lines of "print nothing" to another few hundred lines of "print nothing" means some of us who have substantial work-in-progress patches needs to spend a fair amount of time on rebase, and manually resolving conflicts from rebase.

2013-04-15 04:38:30

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg

On Mon, 2013-04-15 at 05:22 +0100, Hin-Tak Leung wrote:
> How is converting a few hundred lines of "print nothing" to
> another few hundred lines of "print nothing" functional?
> What does it achieve?

Standardization of output style when enabled.
Easier conversion to pr_debug/dynamic_debugging.
Emitting at KERN_DEBUG when enabled.

Besides, I was also doing the other logging
conversions at the same time to prefix hfs
differently than hfsplus.

I don't really care much when this stuff is
done, (it took about 10 minutes and it's about
all automatic and scripted) but I do think it
should be done.