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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Aug 2023 10:17:51 +0800
From:   Yu Kuai <yukuai1@...weicloud.com>
To:     Song Liu <song@...nel.org>, Yu Kuai <yukuai1@...weicloud.com>
Cc:     xni@...hat.com, mariusz.tkaczyk@...ux.intel.com,
        linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
        yi.zhang@...wei.com, yangerkun@...wei.com,
        "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH -next v3 6/7] md: factor out a helper rdev_addable() from
 remove_and_add_spares()

Hi,

在 2023/08/22 7:22, Song Liu 写道:
> On Sun, Aug 20, 2023 at 2:13 AM Yu Kuai <yukuai1@...weicloud.com> wrote:
>>
>> From: Yu Kuai <yukuai3@...wei.com>
>>
>> There are no functional changes, just to make the code simpler and
>> prepare to delay remove_and_add_spares() to md_start_sync().
>>
>> Signed-off-by: Yu Kuai <yukuai3@...wei.com>
>> ---
>>   drivers/md/md.c | 28 ++++++++++++++++------------
>>   1 file changed, 16 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> index 11d27c934fdd..cdc361c521d4 100644
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
>> @@ -9177,6 +9177,20 @@ static bool rdev_is_spare(struct md_rdev *rdev)
>>                 !test_bit(Faulty, &rdev->flags);
>>   }
>>
>> +static bool rdev_addable(struct md_rdev *rdev)
>> +{
>> +       if (test_bit(Candidate, &rdev->flags) || rdev->raid_disk >= 0 ||
>> +           test_bit(Faulty, &rdev->flags))
>> +               return false;
>> +
>> +       if (!test_bit(Journal, &rdev->flags) && !md_is_rdwr(rdev->mddev) &&
> 
> Instead of straightforward refactoring, I hope we can make these rdev_*
> helpers more meaningful, and hopefullly reusable. For example, let's define
> the meaning of "addable", and write the function to match that meaning. In
> this case, I think we shouldn't check md_is_rdwr() inside rdev_addable().
> 
> Does this make sense?

Yes, this make sense, rdev can be added to read-only array.

There are total three callers of pers->hot_add_sisk, I'll try to find if
they have common conditions.

Thanks,
Kuai

> 
> Thanks,
> Song
> 
> 
>> +           !(rdev->saved_raid_disk >= 0 &&
>> +             !test_bit(Bitmap_sync, &rdev->flags)))
>> +               return false;
>> +
>> +       return true;
>> +}
>> +
>>   static int remove_and_add_spares(struct mddev *mddev,
>>                                   struct md_rdev *this)
>>   {
>> @@ -9227,20 +9241,10 @@ static int remove_and_add_spares(struct mddev *mddev,
>>                          continue;
>>                  if (rdev_is_spare(rdev))
>>                          spares++;
>> -               if (test_bit(Candidate, &rdev->flags))
>> +               if (!rdev_addable(rdev))
>>                          continue;
>> -               if (rdev->raid_disk >= 0)
>> -                       continue;
>> -               if (test_bit(Faulty, &rdev->flags))
>> -                       continue;
>> -               if (!test_bit(Journal, &rdev->flags)) {
>> -                       if (!md_is_rdwr(mddev) &&
>> -                           !(rdev->saved_raid_disk >= 0 &&
>> -                             !test_bit(Bitmap_sync, &rdev->flags)))
>> -                               continue;
>> -
>> +               if (!test_bit(Journal, &rdev->flags))
>>                          rdev->recovery_offset = 0;
>> -               }
>>                  if (mddev->pers->hot_add_disk(mddev, rdev) == 0) {
>>                          /* failure here is OK */
>>                          sysfs_link_rdev(mddev, rdev);
>> --
>> 2.39.2
>>
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ