add patch fix-ocfs2-corrupt-when-updating-journal-superblock-fails
[ext4-patch-queue.git] / verify-block-bitmap-even-after-fresh-initialization
blob9ed3f9ab70754c5a835a05cf5e49aef168023513
1 ext4: verify block bitmap even after fresh initialization
3 From: Lukas Czerner <lczerner@redhat.com>
5 If we want to rely on the buffer_verified() flag of the block bitmap
6 buffer, we have to set it consistently. However currently if we're
7 initializing uninitialized block bitmap in
8 ext4_read_block_bitmap_nowait() we're not going to set buffer verified
9 at all.
11 We can do this by simply setting the flag on the buffer, but I think
12 it's actually better to run ext4_validate_block_bitmap() to make sure
13 that what we did in the ext4_init_block_bitmap() is right.
15 So run ext4_validate_block_bitmap() even after the block bitmap
16 initialization. Also bail out early from ext4_validate_block_bitmap() if
17 we see corrupt bitmap, since we already know it's corrupt and we do not
18 need to verify that.
20 Signed-off-by: Lukas Czerner <lczerner@redhat.com>
21 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
22 ---
23 v2: nothing changed
24 v3: nothing changed
26  fs/ext4/balloc.c | 4 ++--
27  1 file changed, 2 insertions(+), 2 deletions(-)
29 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
30 index 955bf49..cd6ea29 100644
31 --- a/fs/ext4/balloc.c
32 +++ b/fs/ext4/balloc.c
33 @@ -369,7 +369,7 @@ static void ext4_validate_block_bitmap(struct super_block *sb,
34         struct ext4_group_info *grp = ext4_get_group_info(sb, block_group);
35         struct ext4_sb_info *sbi = EXT4_SB(sb);
37 -       if (buffer_verified(bh))
38 +       if (buffer_verified(bh) || EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
39                 return;
41         ext4_lock_group(sb, block_group);
42 @@ -446,7 +446,7 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
43                 unlock_buffer(bh);
44                 if (err)
45                         ext4_error(sb, "Checksum bad for grp %u", block_group);
46 -               return bh;
47 +               goto verify;
48         }
49         ext4_unlock_group(sb, block_group);
50         if (buffer_uptodate(bh)) {
51 -- 
52 1.8.3.1
55 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
56 the body of a message to majordomo@vger.kernel.org
57 More majordomo info at  http://vger.kernel.org/majordomo-info.html