2009-11-19 01:13:18

by Toshiyuki Okajima

[permalink] [raw]
Subject: [PATCH][BUG][RFC] ext4: Each meaning of the offset in ext4_check_dir_entry calling from some functions should be unified.

From: Toshiyuki Okajima <[email protected]>

This problem is originated from the one message which has two meanings.
Meanings are:
- File offset
used by:
ext4_readdir, htree_dirblock_to_tree, search_dirblock, ext4_dx_find_entry,
empty_dir
- Buffer offset
used by:
add_dirent_to_buf, ext4_delete_entry

To solve this, there is the method how we change the meaning of add_dirent_to_buf() and
ext4_delete_entry() but it is not easy to change. But we can solve this problem easily
if we unify the meanings into "Buffer offset". So, instead of "File Offset" meaning,
we add the block number information to this message.

--- Examples ---
Original:
EXT4-fs error (device loop0): htree_dirblock_to_tree: bad entry in directory \
#12: rec_len is too small for name_len - offset=12288, inode=216, rec_len=12,\
name_len=11

Change:
EXT4-fs error (device loop0): htree_dirblock_to_tree: bad entry in directory \
#12: rec_len is too small for name_len - block_nr=78:offset=0, inode=216, \
rec_len=12, name_len=11

Signed-off-by: Toshiyuki Okajima <[email protected]>
--
fs/ext4/dir.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff -Nurp linux-2.6.32-rc7.org/fs/ext4/dir.c linux-2.6.32-rc7/fs/ext4/dir.c
--- linux-2.6.32-rc7.org/fs/ext4/dir.c 2009-11-13 09:46:07.000000000 +0900
+++ linux-2.6.32-rc7/fs/ext4/dir.c 2009-11-19 18:32:31.000000000 +0900
@@ -84,9 +84,10 @@ int ext4_check_dir_entry(const char *fun

if (error_msg != NULL)
ext4_error(dir->i_sb, function,
- "bad entry in directory #%lu: %s - "
+ "bad entry in directory #%lu: %s - block_nr=%llu:"
"offset=%u, inode=%u, rec_len=%d, name_len=%d",
- dir->i_ino, error_msg, offset,
+ dir->i_ino, error_msg,
+ (u64)bh->b_blocknr, (u32)(offset%bh->b_size),
le32_to_cpu(de->inode),
rlen, de->name_len);
return error_msg == NULL ? 1 : 0;