[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <45DACE18-A3AD-41B0-B01A-F3B1135A2C0D@dilger.ca>
Date: Mon, 4 Jun 2018 12:09:36 -0600
From: Andreas Dilger <adilger@...ger.ca>
To: Wang Shilong <wangshilong1991@...il.com>
Cc: Ext4 Developers List <linux-ext4@...r.kernel.org>,
Shuichi Ihara <sihara@....com>, Wang Shilong <wshilong@....com>
Subject: Re: [PATCH 3/5] ext4: optimize to reduce redundant ext4_error()
On May 29, 2018, at 5:45 AM, Wang Shilong <wangshilong1991@...il.com> wrote:
>
> From: Wang Shilong <wshilong@....com>
>
> 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@...ger.ca>
> Signed-off-by: Wang Shilong <wshilong@....com>
> ---
>
> 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).
Cheers, Andreas
Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)
Powered by blists - more mailing lists