diff options
author | Wang Shilong <wshilong@ddn.com> | 2018-05-12 11:39:40 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-05-12 11:39:40 -0400 |
commit | db79e6d1fb1f715c961bd880101362e07369de23 (patch) | |
tree | c2030b521e7fdb8c82f39830975d6ab97c76afc2 /fs/ext4/super.c | |
parent | 0db9fdeb347c10f64b679577f2640c9e35ea5a30 (diff) | |
download | linux-db79e6d1fb1f715c961bd880101362e07369de23.tar.bz2 |
ext4: add new ext4_mark_group_bitmap_corrupted() helper
Since there are many places to set inode/block bitmap
corrupt bit, add a new helper for it, which will make
codes more clear.
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index eb104e8476f0..d6d6e7db73d6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -763,6 +763,36 @@ __acquires(bitlock) return; } +void 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); + + if ((flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT) && + !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) { + percpu_counter_sub(&sbi->s_freeclusters_counter, + grp->bb_free); + set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, + &grp->bb_state); + } + + if ((flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT) && + !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { + if (gdp) { + int count; + + count = ext4_free_inodes_count(sb, gdp); + percpu_counter_sub(&sbi->s_freeinodes_counter, + count); + } + set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, + &grp->bb_state); + } +} + void ext4_update_dynamic_rev(struct super_block *sb) { struct ext4_super_block *es = EXT4_SB(sb)->s_es; |