From 5f555ca19aa3fd859839ce273a872bda6a70d9ef Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 12 May 2018 12:27:12 -0400 Subject: [PATCH] add patch mark-inode-bitmap-corrupted-when-found --- mark-inode-bitmap-corrupted-when-found | 79 ++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 +-- 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 mark-inode-bitmap-corrupted-when-found diff --git a/mark-inode-bitmap-corrupted-when-found b/mark-inode-bitmap-corrupted-when-found new file mode 100644 index 00000000..21908cbd --- /dev/null +++ b/mark-inode-bitmap-corrupted-when-found @@ -0,0 +1,79 @@ +ext4: mark inode bitmap corrupted when found + +From: Wang Shilong + +There are still some cases that we missed to set +block bitmaps corrupted bit properly: + +1)inode bitmap number is wrong. +2)failed to read block bitmap due to disk errors. +3)double allocations from bitmap + +Also remove a duplicated call ext4_error() afer +ext4_read_inode_bitmap(), as ext4_error() have been +called inside ext4_read_inode_bitmap() properly. + +Signed-off-by: Wang Shilong +Signed-off-by: Theodore Ts'o +Reviewed-by: Andreas Dilger +--- + fs/ext4/ialloc.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c +index 95611cf9f552..4d6e007f3569 100644 +--- a/fs/ext4/ialloc.c ++++ b/fs/ext4/ialloc.c +@@ -129,6 +129,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) + (bitmap_blk >= ext4_blocks_count(sbi->s_es))) { + ext4_error(sb, "Invalid inode bitmap blk %llu in " + "block_group %u", bitmap_blk, block_group); ++ ext4_mark_group_bitmap_corrupted(sb, block_group, ++ EXT4_GROUP_INFO_IBITMAP_CORRUPT); + return ERR_PTR(-EFSCORRUPTED); + } + bh = sb_getblk(sb, bitmap_blk); +@@ -183,6 +185,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) + ext4_error(sb, "Cannot read inode bitmap - " + "block_group = %u, inode_bitmap = %llu", + block_group, bitmap_blk); ++ ext4_mark_group_bitmap_corrupted(sb, block_group, ++ EXT4_GROUP_INFO_IBITMAP_CORRUPT); + return ERR_PTR(-EIO); + } + +@@ -902,6 +906,8 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, + if (group == 0 && (ino + 1) < EXT4_FIRST_INO(sb)) { + ext4_error(sb, "reserved inode found cleared - " + "inode=%lu", ino + 1); ++ ext4_mark_group_bitmap_corrupted(sb, group, ++ EXT4_GROUP_INFO_IBITMAP_CORRUPT); + goto next_group; + } + +@@ -1093,6 +1099,8 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, + err = -EIO; + ext4_error(sb, "failed to insert inode %lu: doubly allocated?", + inode->i_ino); ++ ext4_mark_group_bitmap_corrupted(sb, group, ++ EXT4_GROUP_INFO_IBITMAP_CORRUPT); + goto out; + } + inode->i_generation = prandom_u32(); +@@ -1194,11 +1202,8 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) + block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); + bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); + bitmap_bh = ext4_read_inode_bitmap(sb, block_group); +- if (IS_ERR(bitmap_bh)) { +- ext4_error(sb, "inode bitmap error %ld for orphan %lu", +- ino, PTR_ERR(bitmap_bh)); ++ if (IS_ERR(bitmap_bh)) + return (struct inode *) bitmap_bh; +- } + + /* Having the inode bit set should be a 100% indicator that this + * is a valid orphan (no e2fsck run on fs). Orphans also include +-- +2.14.3 + + diff --git a/series b/series index cb1245ed..99dfac63 100644 --- a/series +++ b/series @@ -5,6 +5,7 @@ use-XATTR_CREATE-in-ext4_initxattrs use-raw_iversion-value-for-ea_inode fix-wrong-return-value-in-ext4_read_inode_bitmap new-ext4_mark_group_bitmap_corrupted-helper +mark-inode-bitmap-corrupted-when-found #################################################### # unstable patches diff --git a/timestamps b/timestamps index 437e784c..3c1968c5 100755 --- a/timestamps +++ b/timestamps @@ -39,6 +39,7 @@ touch -d @1525967731 use-raw_iversion-value-for-ea_inode touch -d @1525967791 stable-boundary touch -d @1526139301 fix-wrong-return-value-in-ext4_read_inode_bitmap touch -d @1526139580 new-ext4_mark_group_bitmap_corrupted-helper -touch -d @1526139729 series -touch -d @1526139735 status -touch -d @1526141582 timestamps +touch -d @1526141721 mark-inode-bitmap-corrupted-when-found +touch -d @1526141730 series +touch -d @1526141735 status +touch -d @1526142394 timestamps -- 2.11.4.GIT