Skip to content

Commit

Permalink
erofs: rename errln/infoln/debugln to erofs_{err, info, dbg}
Browse files Browse the repository at this point in the history
Add prefix "erofs_" to these functions and print
sb->s_id as a prefix to erofs_{err, info} so that
the user knows which file system is affected.

Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190904020912.63925-23-gaoxiang25@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Gao Xiang authored and Greg Kroah-Hartman committed Sep 5, 2019
1 parent 84947eb commit 4f761fa
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 90 deletions.
10 changes: 6 additions & 4 deletions fs/erofs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,19 @@ static int erofs_map_blocks_flatmode(struct inode *inode,

/* inline data should be located in one meta block */
if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
errln("inline data cross block boundary @ nid %llu",
vi->nid);
erofs_err(inode->i_sb,
"inline data cross block boundary @ nid %llu",
vi->nid);
DBG_BUGON(1);
err = -EFSCORRUPTED;
goto err_out;
}

map->m_flags |= EROFS_MAP_META;
} else {
errln("internal error @ nid: %llu (size %llu), m_la 0x%llx",
vi->nid, inode->i_size, map->m_la);
erofs_err(inode->i_sb,
"internal error @ nid: %llu (size %llu), m_la 0x%llx",
vi->nid, inode->i_size, map->m_la);
DBG_BUGON(1);
err = -EIO;
goto err_out;
Expand Down
5 changes: 2 additions & 3 deletions fs/erofs/decompressor.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
inlen, rq->outputsize,
rq->outputsize);
if (ret < 0) {
errln("%s, failed to decompress, in[%p, %u, %u] out[%p, %u]",
__func__, src + inputmargin, inlen, inputmargin,
out, rq->outputsize);
erofs_err(rq->sb, "failed to decompress, in[%u, %u] out[%u]",
inlen, inputmargin, rq->outputsize);
WARN_ON(1);
print_hex_dump(KERN_DEBUG, "[ in]: ", DUMP_PREFIX_OFFSET,
16, 1, src + inputmargin, inlen, true);
Expand Down
17 changes: 10 additions & 7 deletions fs/erofs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ static void debug_one_dentry(unsigned char d_type, const char *de_name,
memcpy(dbg_namebuf, de_name, de_namelen);
dbg_namebuf[de_namelen] = '\0';

debugln("found dirent %s de_len %u d_type %d", dbg_namebuf,
de_namelen, d_type);
erofs_dbg("found dirent %s de_len %u d_type %d", dbg_namebuf,
de_namelen, d_type);
#endif
}

Expand Down Expand Up @@ -47,7 +47,8 @@ static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx,
/* a corrupted entry is found */
if (nameoff + de_namelen > maxsize ||
de_namelen > EROFS_NAME_LEN) {
errln("bogus dirent @ nid %llu", EROFS_I(dir)->nid);
erofs_err(dir->i_sb, "bogus dirent @ nid %llu",
EROFS_I(dir)->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
Expand Down Expand Up @@ -84,8 +85,9 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
err = -ENOMEM;
break;
} else if (IS_ERR(dentry_page)) {
errln("fail to readdir of logical block %u of nid %llu",
i, EROFS_I(dir)->nid);
erofs_err(dir->i_sb,
"fail to readdir of logical block %u of nid %llu",
i, EROFS_I(dir)->nid);
err = -EFSCORRUPTED;
break;
}
Expand All @@ -96,8 +98,9 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)

if (nameoff < sizeof(struct erofs_dirent) ||
nameoff >= PAGE_SIZE) {
errln("%s, invalid de[0].nameoff %u @ nid %llu",
__func__, nameoff, EROFS_I(dir)->nid);
erofs_err(dir->i_sb,
"invalid de[0].nameoff %u @ nid %llu",
nameoff, EROFS_I(dir)->nid);
err = -EFSCORRUPTED;
goto skip_this;
}
Expand Down
31 changes: 17 additions & 14 deletions fs/erofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ static int erofs_read_inode(struct inode *inode, void *data)
vi->datalayout = erofs_inode_datalayout(ifmt);

if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
errln("unsupported datalayout %u of nid %llu",
vi->datalayout, vi->nid);
erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
vi->datalayout, vi->nid);
DBG_BUGON(1);
return -EOPNOTSUPP;
}
Expand Down Expand Up @@ -108,8 +108,9 @@ static int erofs_read_inode(struct inode *inode, void *data)
nblks = le32_to_cpu(dic->i_u.compressed_blocks);
break;
default:
errln("unsupported on-disk inode version %u of nid %llu",
erofs_inode_version(ifmt), vi->nid);
erofs_err(inode->i_sb,
"unsupported on-disk inode version %u of nid %llu",
erofs_inode_version(ifmt), vi->nid);
DBG_BUGON(1);
return -EOPNOTSUPP;
}
Expand All @@ -122,7 +123,8 @@ static int erofs_read_inode(struct inode *inode, void *data)
return 0;

bogusimode:
errln("bogus i_mode (%o) @ nid %llu", inode->i_mode, vi->nid);
erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu",
inode->i_mode, vi->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
Expand All @@ -148,8 +150,9 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
/* inline symlink data shouldn't cross page boundary as well */
if (m_pofs + inode->i_size > PAGE_SIZE) {
kfree(lnk);
errln("inline data cross block boundary @ nid %llu",
vi->nid);
erofs_err(inode->i_sb,
"inline data cross block boundary @ nid %llu",
vi->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
Expand All @@ -164,7 +167,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,

static int erofs_fill_inode(struct inode *inode, int isdir)
{
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
struct super_block *sb = inode->i_sb;
struct erofs_inode *vi = EROFS_I(inode);
struct page *page;
void *data;
Expand All @@ -174,18 +177,18 @@ static int erofs_fill_inode(struct inode *inode, int isdir)
erofs_off_t inode_loc;

trace_erofs_fill_inode(inode, isdir);
inode_loc = iloc(sbi, vi->nid);
inode_loc = iloc(EROFS_SB(sb), vi->nid);
blkaddr = erofs_blknr(inode_loc);
ofs = erofs_blkoff(inode_loc);

debugln("%s, reading inode nid %llu at %u of blkaddr %u",
__func__, vi->nid, ofs, blkaddr);
erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u",
__func__, vi->nid, ofs, blkaddr);

page = erofs_get_meta_page(inode->i_sb, blkaddr);
page = erofs_get_meta_page(sb, blkaddr);

if (IS_ERR(page)) {
errln("failed to get inode (nid: %llu) page, err %ld",
vi->nid, PTR_ERR(page));
erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
vi->nid, PTR_ERR(page));
return PTR_ERR(page);
}

Expand Down
14 changes: 10 additions & 4 deletions fs/erofs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
#undef pr_fmt
#define pr_fmt(fmt) "erofs: " fmt

#define errln(x, ...) pr_err(x "\n", ##__VA_ARGS__)
#define infoln(x, ...) pr_info(x "\n", ##__VA_ARGS__)
__printf(3, 4) void _erofs_err(struct super_block *sb,
const char *function, const char *fmt, ...);
#define erofs_err(sb, fmt, ...) \
_erofs_err(sb, __func__, fmt "\n", ##__VA_ARGS__)
__printf(3, 4) void _erofs_info(struct super_block *sb,
const char *function, const char *fmt, ...);
#define erofs_info(sb, fmt, ...) \
_erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)
#ifdef CONFIG_EROFS_FS_DEBUG
#define debugln(x, ...) pr_debug(x "\n", ##__VA_ARGS__)
#define erofs_dbg(x, ...) pr_debug(x "\n", ##__VA_ARGS__)
#define DBG_BUGON BUG_ON
#else
#define debugln(x, ...) ((void)0)
#define erofs_dbg(x, ...) ((void)0)
#define DBG_BUGON(x) ((void)(x))
#endif /* !CONFIG_EROFS_FS_DEBUG */

Expand Down
9 changes: 5 additions & 4 deletions fs/erofs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ static struct page *find_target_block_classic(struct inode *dir,
if (!ndirents) {
kunmap_atomic(de);
put_page(page);
errln("corrupted dir block %d @ nid %llu",
mid, EROFS_I(dir)->nid);
erofs_err(dir->i_sb,
"corrupted dir block %d @ nid %llu",
mid, EROFS_I(dir)->nid);
DBG_BUGON(1);
page = ERR_PTR(-EFSCORRUPTED);
goto out;
Expand Down Expand Up @@ -233,8 +234,8 @@ static struct dentry *erofs_lookup(struct inode *dir,
} else if (err) {
inode = ERR_PTR(err);
} else {
debugln("%s, %s (nid %llu) found, d_type %u", __func__,
dentry->d_name.name, nid, d_type);
erofs_dbg("%s, %s (nid %llu) found, d_type %u", __func__,
dentry->d_name.name, nid, d_type);
inode = erofs_iget(dir->i_sb, nid, d_type == FT_DIR);
}
return d_splice_alias(inode, dentry);
Expand Down
Loading

0 comments on commit 4f761fa

Please sign in to comment.