Skip to content

Commit

Permalink
ext4: Pass line numbers to ext4_error() and friends
Browse files Browse the repository at this point in the history
Signed-off-by: "Theodore Ts'o" <[email protected]>
  • Loading branch information
tytso committed Jul 27, 2010
1 parent 60fd4da commit c398eda
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 80 deletions.
7 changes: 3 additions & 4 deletions fs/ext4/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
error_msg = "inode out of bounds";

if (error_msg != NULL)
ext4_error_inode(function, dir,
"bad entry in directory: %s - block=%llu"
ext4_error_inode(dir, function, line, bh->b_blocknr,
"bad entry in directory: %s - "
"offset=%u(%u), inode=%u, rec_len=%d, name_len=%d",
error_msg, (unsigned long long) bh->b_blocknr,
(unsigned) (offset%bh->b_size), offset,
error_msg, (unsigned) (offset%bh->b_size), offset,
le32_to_cpu(de->inode),
rlen, de->name_len);
return error_msg == NULL ? 1 : 0;
Expand Down
44 changes: 27 additions & 17 deletions fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@
#endif

#define EXT4_ERROR_INODE(inode, fmt, a...) \
ext4_error_inode(__func__, (inode), (fmt), ## a)
ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a)

#define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \
ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a)

#define EXT4_ERROR_FILE(file, fmt, a...) \
ext4_error_file(__func__, (file), (fmt), ## a)
ext4_error_file(__func__, __LINE__, (file), (fmt), ## a)

/* data type for block offset of block group */
typedef int ext4_grpblk_t;
Expand Down Expand Up @@ -1623,22 +1626,29 @@ extern int ext4_group_extend(struct super_block *sb,
ext4_fsblk_t n_blocks_count);

/* super.c */
extern void __ext4_error(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message)
extern void ext4_error_inode(const char *, struct inode *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void ext4_error_file(const char *, struct file *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void __ext4_std_error(struct super_block *, const char *, int);
extern void __ext4_abort(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void __ext4_error(struct super_block *, const char *, unsigned int,
const char *, ...)
__attribute__ ((format (printf, 4, 5)));
#define ext4_error(sb, message...) __ext4_error(sb, __func__, \
__LINE__, ## message)
extern void ext4_error_inode(struct inode *, const char *, unsigned int,
ext4_fsblk_t, const char *, ...)
__attribute__ ((format (printf, 5, 6)));
extern void ext4_error_file(struct file *, const char *, unsigned int,
const char *, ...)
__attribute__ ((format (printf, 4, 5)));
extern void __ext4_std_error(struct super_block *, const char *,
unsigned int, int);
extern void __ext4_abort(struct super_block *, const char *, unsigned int,
const char *, ...)
__attribute__ ((format (printf, 4, 5)));
#define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \
## message)
extern void __ext4_warning(struct super_block *, const char *,
__LINE__, ## message)
extern void __ext4_warning(struct super_block *, const char *, unsigned int,
const char *, ...)
__attribute__ ((format (printf, 3, 4)));
#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message)
__attribute__ ((format (printf, 4, 5)));
#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \
__LINE__, ## message)
extern void ext4_msg(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void __ext4_grp_locked_error(const char *, unsigned int, \
Expand Down Expand Up @@ -1781,7 +1791,7 @@ static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
#define ext4_std_error(sb, errno) \
do { \
if ((errno)) \
__ext4_std_error((sb), __func__, (errno)); \
__ext4_std_error((sb), __func__, __LINE__, (errno)); \
} while (0)

#ifdef CONFIG_SMP
Expand Down
12 changes: 5 additions & 7 deletions fs/ext4/ext4_jbd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
if (err) {
ext4_journal_abort_handle(where, line, __func__,
bh, handle, err);
__ext4_abort(inode->i_sb, where,
"error %d when attempting revoke", err);
__ext4_abort(inode->i_sb, where, line,
"error %d when attempting revoke", err);
}
BUFFER_TRACE(bh, "exit");
return err;
Expand Down Expand Up @@ -134,11 +134,9 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
if (inode && inode_needs_sync(inode)) {
sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh)) {
ext4_error(inode->i_sb,
"IO error syncing inode, "
"inode=%lu, block=%llu",
inode->i_ino,
(unsigned long long) bh->b_blocknr);
ext4_error_inode(inode, where, line,
bh->b_blocknr,
"IO error syncing itable block");
err = -EIO;
}
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/ext4_jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line,
__ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb))

handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
int __ext4_journal_stop(const char *where, handle_t *handle);
int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle);

#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096)

Expand Down Expand Up @@ -215,7 +215,7 @@ static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
}

#define ext4_journal_stop(handle) \
__ext4_journal_stop(__func__, (handle))
__ext4_journal_stop(__func__, __LINE__, (handle))

static inline handle_t *ext4_journal_current_handle(void)
{
Expand Down
10 changes: 5 additions & 5 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ static int ext4_valid_extent_entries(struct inode *inode,
return 1;
}

static int __ext4_ext_check(const char *function, struct inode *inode,
struct ext4_extent_header *eh,
int depth)
static int __ext4_ext_check(const char *function, unsigned int line,
struct inode *inode, struct ext4_extent_header *eh,
int depth)
{
const char *error_msg;
int max = 0;
Expand Down Expand Up @@ -436,7 +436,7 @@ static int __ext4_ext_check(const char *function, struct inode *inode,
return 0;

corrupted:
ext4_error_inode(function, inode,
ext4_error_inode(inode, function, line, 0,
"bad header/extent: %s - magic %x, "
"entries %u, max %u(%u), depth %u(%u)",
error_msg, le16_to_cpu(eh->eh_magic),
Expand All @@ -447,7 +447,7 @@ static int __ext4_ext_check(const char *function, struct inode *inode,
}

#define ext4_ext_check(inode, eh, depth) \
__ext4_ext_check(__func__, inode, eh, depth)
__ext4_ext_check(__func__, __LINE__, inode, eh, depth)

int ext4_ext_check_inode(struct inode *inode)
{
Expand Down
44 changes: 23 additions & 21 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ static int ext4_block_to_path(struct inode *inode,
return n;
}

static int __ext4_check_blockref(const char *function, struct inode *inode,
static int __ext4_check_blockref(const char *function, unsigned int line,
struct inode *inode,
__le32 *p, unsigned int max)
{
__le32 *bref = p;
Expand All @@ -348,8 +349,8 @@ static int __ext4_check_blockref(const char *function, struct inode *inode,
if (blk &&
unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
blk, 1))) {
ext4_error_inode(function, inode,
"invalid block reference %u", blk);
ext4_error_inode(inode, function, line, blk,
"invalid block");
return -EIO;
}
}
Expand All @@ -358,11 +359,13 @@ static int __ext4_check_blockref(const char *function, struct inode *inode,


#define ext4_check_indirect_blockref(inode, bh) \
__ext4_check_blockref(__func__, inode, (__le32 *)(bh)->b_data, \
__ext4_check_blockref(__func__, __LINE__, inode, \
(__le32 *)(bh)->b_data, \
EXT4_ADDR_PER_BLOCK((inode)->i_sb))

#define ext4_check_inode_blockref(inode) \
__ext4_check_blockref(__func__, inode, EXT4_I(inode)->i_data, \
__ext4_check_blockref(__func__, __LINE__, inode, \
EXT4_I(inode)->i_data, \
EXT4_NDIR_BLOCKS)

/**
Expand Down Expand Up @@ -1129,21 +1132,22 @@ void ext4_da_update_reserve_space(struct inode *inode,
}

static int __check_block_validity(struct inode *inode, const char *func,
struct ext4_map_blocks *map)
unsigned int line,
struct ext4_map_blocks *map)
{
if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,
map->m_len)) {
ext4_error_inode(func, inode,
"lblock %lu mapped to illegal pblock %llu "
"(length %d)", (unsigned long) map->m_lblk,
map->m_pblk, map->m_len);
ext4_error_inode(inode, func, line, map->m_pblk,
"lblock %lu mapped to illegal pblock "
"(length %d)", (unsigned long) map->m_lblk,
map->m_len);
return -EIO;
}
return 0;
}

#define check_block_validity(inode, map) \
__check_block_validity((inode), __func__, (map))
__check_block_validity((inode), __func__, __LINE__, (map))

/*
* Return the number of contiguous dirty pages in a given inode
Expand Down Expand Up @@ -4471,9 +4475,8 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
* (should be rare).
*/
if (!bh) {
EXT4_ERROR_INODE(inode,
"Read failure block=%llu",
(unsigned long long) nr);
EXT4_ERROR_INODE_BLOCK(inode, nr,
"Read failure");
continue;
}

Expand Down Expand Up @@ -4788,8 +4791,8 @@ static int __ext4_get_inode_loc(struct inode *inode,

bh = sb_getblk(sb, block);
if (!bh) {
EXT4_ERROR_INODE(inode, "unable to read inode block - "
"block %llu", block);
EXT4_ERROR_INODE_BLOCK(inode, block,
"unable to read itable block");
return -EIO;
}
if (!buffer_uptodate(bh)) {
Expand Down Expand Up @@ -4887,8 +4890,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
submit_bh(READ_META, bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
EXT4_ERROR_INODE(inode, "unable to read inode "
"block %llu", block);
EXT4_ERROR_INODE_BLOCK(inode, block,
"unable to read itable block");
brelse(bh);
return -EIO;
}
Expand Down Expand Up @@ -5389,9 +5392,8 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
if (wbc->sync_mode == WB_SYNC_ALL)
sync_dirty_buffer(iloc.bh);
if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
EXT4_ERROR_INODE(inode,
"IO error syncing inode (block=%llu)",
(unsigned long long) iloc.bh->b_blocknr);
EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr,
"IO error syncing inode");
err = -EIO;
}
brelse(iloc.bh);
Expand Down
10 changes: 5 additions & 5 deletions fs/ext4/move_extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ mext_next_extent(struct inode *inode, struct ext4_ext_path *path,
*/
static int
mext_check_null_inode(struct inode *inode1, struct inode *inode2,
const char *function)
const char *function, unsigned int line)
{
int ret = 0;

if (inode1 == NULL) {
__ext4_error(inode2->i_sb, function,
__ext4_error(inode2->i_sb, function, line,
"Both inodes should not be NULL: "
"inode1 NULL inode2 %lu", inode2->i_ino);
ret = -EIO;
} else if (inode2 == NULL) {
__ext4_error(inode1->i_sb, function,
__ext4_error(inode1->i_sb, function, line,
"Both inodes should not be NULL: "
"inode1 %lu inode2 NULL", inode1->i_ino);
ret = -EIO;
Expand Down Expand Up @@ -1084,7 +1084,7 @@ mext_inode_double_lock(struct inode *inode1, struct inode *inode2)

BUG_ON(inode1 == NULL && inode2 == NULL);

ret = mext_check_null_inode(inode1, inode2, __func__);
ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__);
if (ret < 0)
goto out;

Expand Down Expand Up @@ -1121,7 +1121,7 @@ mext_inode_double_unlock(struct inode *inode1, struct inode *inode2)

BUG_ON(inode1 == NULL && inode2 == NULL);

ret = mext_check_null_inode(inode1, inode2, __func__);
ret = mext_check_null_inode(inode1, inode2, __func__, __LINE__);
if (ret < 0)
goto out;

Expand Down
Loading

0 comments on commit c398eda

Please sign in to comment.