lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A4811232-C245-45A9-ACB6-EBC9FCDBF601@ddn.com>
Date:   Mon, 4 Jun 2018 23:41:40 +0000
From:   Wang Shilong <wshilong@....com>
To:     Andreas Dilger <adilger@...ger.ca>
CC:     Wang Shilong <wangshilong1991@...il.com>,
        "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
        Shuichi Ihara <sihara@....com>
Subject: Re: [PATCH 3/5] ext4: optimize to reduce redundant ext4_error()

Andreas,

> 
> 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).
> 

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
> 
> 
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ