Commit 398d6fad921ec0bc82ae98250831216a363c38b6
Committed by
Tom Rini
1 parent
b7dd40d052
Exists in
v2017.01-smarct4x
and in
25 other branches
ext4: Only update number of of unused inodes if GDT_CSUM feature is set
e2fsck warns about "Group descriptor 0 marked uninitialized without feature set." The bg_itable_unused field is only defined if FEATURE_RO_COMPAT_GDT_CSUM is set, and should be set (kept) zero otherwise. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Showing 1 changed file with 7 additions and 7 deletions Side-by-side Diff
fs/ext4/ext4_common.c
... | ... | @@ -988,12 +988,13 @@ |
988 | 988 | if (!journal_buffer || !zero_buffer) |
989 | 989 | goto fail; |
990 | 990 | struct ext2_block_group *bgd = (struct ext2_block_group *)fs->gdtable; |
991 | + int has_gdt_chksum = le32_to_cpu(fs->sb->feature_ro_compat) & | |
992 | + EXT4_FEATURE_RO_COMPAT_GDT_CSUM ? 1 : 0; | |
991 | 993 | |
992 | 994 | if (fs->first_pass_ibmap == 0) { |
993 | 995 | for (i = 0; i < fs->no_blkgrp; i++) { |
994 | 996 | if (bgd[i].free_inodes) { |
995 | - if (bgd[i].bg_itable_unused != | |
996 | - bgd[i].free_inodes) | |
997 | + if (has_gdt_chksum) | |
997 | 998 | bgd[i].bg_itable_unused = |
998 | 999 | bgd[i].free_inodes; |
999 | 1000 | if (le16_to_cpu(bgd[i].bg_flags) & EXT4_BG_INODE_UNINIT) { |
... | ... | @@ -1014,7 +1015,8 @@ |
1014 | 1015 | (i * inodes_per_grp); |
1015 | 1016 | fs->first_pass_ibmap++; |
1016 | 1017 | ext4fs_bg_free_inodes_dec(&bgd[i]); |
1017 | - ext4fs_bg_itable_unused_dec(&bgd[i]); | |
1018 | + if (has_gdt_chksum) | |
1019 | + ext4fs_bg_itable_unused_dec(&bgd[i]); | |
1018 | 1020 | ext4fs_sb_free_inodes_dec(fs->sb); |
1019 | 1021 | status = ext4fs_devread( |
1020 | 1022 | (lbaint_t)le32_to_cpu(bgd[i].inode_id) * |
1021 | 1023 | |
... | ... | @@ -1069,12 +1071,10 @@ |
1069 | 1071 | goto fail; |
1070 | 1072 | prev_inode_bitmap_index = ibmap_idx; |
1071 | 1073 | } |
1072 | - if (bgd[ibmap_idx].bg_itable_unused != | |
1073 | - bgd[ibmap_idx].free_inodes) | |
1074 | + ext4fs_bg_free_inodes_dec(&bgd[ibmap_idx]); | |
1075 | + if (has_gdt_chksum) | |
1074 | 1076 | bgd[ibmap_idx].bg_itable_unused = |
1075 | 1077 | bgd[ibmap_idx].free_inodes; |
1076 | - ext4fs_bg_free_inodes_dec(&bgd[ibmap_idx]); | |
1077 | - ext4fs_bg_itable_unused_dec(&bgd[ibmap_idx]); | |
1078 | 1078 | ext4fs_sb_free_inodes_dec(fs->sb); |
1079 | 1079 | goto success; |
1080 | 1080 | } |