Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934057AbbGVKk3 (ORCPT ); Wed, 22 Jul 2015 06:40:29 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:39048 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933440AbbGVKk0 (ORCPT ); Wed, 22 Jul 2015 06:40:26 -0400 X-AuditID: cbfee61a-f79516d000006302-93-55af7318b354 From: Bartlomiej Zolnierkiewicz To: Beata Michalska , tytso@mit.edu Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, greg@kroah.com, jack@suse.cz, adilger.kernel@dilger.ca, hughd@google.com, lczerner@redhat.com, hch@infradead.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, kyungmin.park@samsung.com, kmpark@infradead.org Subject: Re: [RFC v3 2/4] ext4: Add helper function to mark group as corrupted Date: Wed, 22 Jul 2015 12:40:03 +0200 Message-id: <3417027.tdShitEpvE@amdc1976> User-Agent: KMail/4.13.3 (Linux/3.13.0-57-generic; KDE/4.13.3; x86_64; ; ) In-reply-to: <1434460173-18427-3-git-send-email-b.michalska@samsung.com> References: <1434460173-18427-1-git-send-email-b.michalska@samsung.com> <1434460173-18427-3-git-send-email-b.michalska@samsung.com> MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRmVeSWpSXmKPExsVy+t9jQV2J4vWhBt9uC1p8/dLBYjFtRj+7 xbkFMxgtTk9YxGTx9FMfi8Xs6c1MFrcur2KxONv0ht1i2YPNLBabv3ewWcycd4fNYs/ekywW l3fNYbO4t+Y/q0Vrz092B36Pls3lHgs2lXpsXqHl8fZhgMemT5PYPZrOHGX2eL/vKptH35ZV jB5nFhxh9/i8SS6AK4rLJiU1J7MstUjfLoErY+GE48wFLzQqDt1/xNzAuFKxi5GTQ0LAROLC uXnMELaYxIV769m6GLk4hASmM0q8n/OOGcL5yihx7utBNpAqNgEriYntqxhBbBEBG4n/z28x ghQxC2xlkph05w4TSEJYwE/i1q2NYDaLgKpE17kvrCA2r4CmRN/EtWCDRAW8JL7/agBbzSng IXFo6RsmiG2tjBLrV39igmgQlPgx+R4LiM0sIC+xb/9UVghbS2L9zuNMExgFZiEpm4WkbBaS sgWMzKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgqPsmdQOxpUNFocYBTgYlXh4JxxdFyrE mlhWXJl7iFGCg1lJhPdF1vpQId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwn831ChQTSE0tSs1NT C1KLYLJMHJxSDYzBMUyXN75MuTrhde78S2sftuzflXjvVvqVd7YPUlK8eV+f27qsT9EiU9VU 0t1z7cqNLw4wfN9+R82CgbvvbXdY0e7Q1jMHvE2WWfzyyZxUm/LE6+ilVvuTmldtw0S1dLIK w/O11OIchZ9fvHdlf6m80efApd2W2bcfpXYv1XU+PbdCOOvNC2ElluKMREMt5qLiRABIKDqq rgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5338 Lines: 138 Hi, On Tuesday, June 16, 2015 03:09:31 PM Beata Michalska wrote: > Add ext4_mark_group_corrupted helper function to > simplify the code and to keep the logic in one place. > > Signed-off-by: Beata Michalska This small cleanup patch is not really required for your notifications framework to work and it seems to be a good change on its own. Maybe it can be merged independently of other patches? Ted, what is your opinion on it? Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics > --- > fs/ext4/balloc.c | 15 +++------------ > fs/ext4/ext4.h | 9 +++++++++ > fs/ext4/ialloc.c | 5 +---- > fs/ext4/mballoc.c | 11 ++--------- > 4 files changed, 15 insertions(+), 25 deletions(-) > > diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c > index 83a6f49..e95b27a 100644 > --- a/fs/ext4/balloc.c > +++ b/fs/ext4/balloc.c > @@ -193,10 +193,7 @@ static int ext4_init_block_bitmap(struct super_block *sb, > * essentially implementing a per-group read-only flag. */ > if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { > grp = ext4_get_group_info(sb, block_group); > - if (!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); > + ext4_mark_group_corrupted(sbi, grp); > if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { > int count; > count = ext4_free_inodes_count(sb, gdp); > @@ -379,20 +376,14 @@ static void ext4_validate_block_bitmap(struct super_block *sb, > ext4_unlock_group(sb, block_group); > ext4_error(sb, "bg %u: block %llu: invalid block bitmap", > block_group, blk); > - if (!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); > + ext4_mark_group_corrupted(sbi, grp); > return; > } > if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, > desc, bh))) { > ext4_unlock_group(sb, block_group); > ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); > - if (!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); > + ext4_mark_group_corrupted(sbi, grp); > return; > } > set_buffer_verified(bh); > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index f63c3d5..163afe2 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -2535,6 +2535,15 @@ static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb, > return bgl_lock_ptr(EXT4_SB(sb)->s_blockgroup_lock, group); > } > > +static inline > +void ext4_mark_group_corrupted(struct ext4_sb_info *sbi, > + struct ext4_group_info *grp) > +{ > + if (!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); > +} > + > /* > * Returns true if the filesystem is busy enough that attempts to > * access the block group locks has run into contention. > diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c > index ac644c3..ebe0499 100644 > --- a/fs/ext4/ialloc.c > +++ b/fs/ext4/ialloc.c > @@ -79,10 +79,7 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, > if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { > ext4_error(sb, "Checksum bad for group %u", block_group); > grp = ext4_get_group_info(sb, block_group); > - if (!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); > + ext4_mark_group_corrupted(sbi, grp); > if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { > int count; > count = ext4_free_inodes_count(sb, gdp); > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 8d1e602..24a4b6d 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -760,10 +760,7 @@ void ext4_mb_generate_buddy(struct super_block *sb, > * corrupt and update bb_free using bitmap value > */ > grp->bb_free = free; > - if (!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); > + ext4_mark_group_corrupted(sbi, grp); > } > mb_set_largest_free_order(sb, grp); > > @@ -1448,12 +1445,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, > "freeing already freed block " > "(bit %u); block bitmap corrupt.", > block); > - if (!EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)) > - percpu_counter_sub(&sbi->s_freeclusters_counter, > - e4b->bd_info->bb_free); > /* Mark the block group as corrupt. */ > - set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, > - &e4b->bd_info->bb_state); > + ext4_mark_group_corrupted(sbi, e4b->bd_info); > mb_regenerate_buddy(e4b); > goto done; > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/