Andreas, > > On May 29, 2018, at 5:45 AM, Wang Shilong <wangshilong1991@xxxxxxxxx> wrote: >> >> From: Wang Shilong <wshilong@xxxxxxx> >> >> only call ext4_error() if new corrupted bit set, >> this could save us repeated error messages and >> unecessary super block write. >> >> Suggested-by: Andreas Dilger <adilger@xxxxxxxxx> >> Signed-off-by: Wang Shilong <wshilong@xxxxxxx> >> --- >> >> diff --git a/fs/ext4/super.c b/fs/ext4/super.c >> index 554bceb..9f88991 100644 >> --- a/fs/ext4/super.c >> +++ b/fs/ext4/super.c >> @@ -766,21 +766,24 @@ void __ext4_grp_locked_error(const char *function, >> >> -void __ext4_mark_group_bitmap_corrupted(struct super_block *sb, >> - ext4_group_t group, >> - unsigned int flags) >> +int __ext4_mark_group_bitmap_corrupted(struct super_block *sb, >> + ext4_group_t group, >> + unsigned int flags) >> { >> struct ext4_sb_info *sbi = EXT4_SB(sb); >> struct ext4_group_info *grp = ext4_get_group_info(sb, group); >> struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); >> int ret; >> + int set = 0; >> >> if (flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT) { >> ret = ext4_test_and_set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, >> &grp->bb_state); >> - if (!ret) >> + if (!ret) { >> percpu_counter_sub(&sbi->s_freeclusters_counter, >> grp->bb_free); >> + set = 1; >> + } >> } >> >> if (flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT) { >> @@ -792,8 +795,11 @@ void __ext4_mark_group_bitmap_corrupted(struct super_block *sb, >> count = ext4_free_inodes_count(sb, gdp); >> percpu_counter_sub(&sbi->s_freeinodes_counter, >> count); >> + set = 1; >> } >> } >> + >> + return set; > > Instead of adding a separate "set" variable, why not initialize "ret = 0" > and then return "!ret"? It might be better to rename "ret" to something > more useful like "was_set" (which could be done in the original 1/5 patch). > This doesn’t work, because it is possible that we don’t set any bit for the flags passed in. Or we could change it to: If (flags & (EXT4_GROUP_INFO_IBITMAP_CORRUPT | EXT4_GROUP_INFO_BBITMAP_CORRUPT) && !ret) return 1; else return 0; Instead of something like this, introduced another bool value looks more readable? > Cheers, Andreas > > > > >