From: Yu Kuai <yukuai1@huaweicloud.com>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: xni@redhat.com, mariusz.tkaczyk@linux.intel.com,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com, yangerkun@huawei.com,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH -next v3 6/7] md: factor out a helper rdev_addable() from remove_and_add_spares()
Date: Tue, 22 Aug 2023 10:17:51 +0800 [thread overview]
Message-ID: <c7a82fb2-cf4b-2095-e813-84aed2418ff0@huaweicloud.com> (raw)
In-Reply-To: <CAPhsuW74MEFjNTNErYfOT1gX+BUdbDwaV1oTmmcz=_76Ym3ZuA@mail.gmail.com>
Hi,
在 2023/08/22 7:22, Song Liu 写道:
> On Sun, Aug 20, 2023 at 2:13 AM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>>
>> From: Yu Kuai <yukuai3@huawei.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@huawei.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
>>
> .
>
next prev parent reply other threads:[~2023-08-22 2:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-20 9:09 [PATCH -next v3 0/7] md: make rdev addition and removal independent from daemon thread Yu Kuai
2023-08-20 9:09 ` [PATCH -next v3 1/7] md: use separate work_struct for md_start_sync() Yu Kuai
2023-08-22 10:04 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 2/7] md: factor out a helper to choose sync action from md_check_recovery() Yu Kuai
2023-08-22 10:04 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 3/7] md: delay choosing sync action to md_start_sync() Yu Kuai
2023-08-22 10:06 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 4/7] md: factor out a helper rdev_removeable() from remove_and_add_spares() Yu Kuai
2023-08-22 10:19 ` Xiao Ni
2023-08-23 2:45 ` Yu Kuai
2023-08-23 3:42 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 5/7] md: factor out a helper rdev_is_spare() " Yu Kuai
2023-08-23 2:20 ` Xiao Ni
2023-08-23 2:28 ` Xiao Ni
2023-08-23 2:47 ` Yu Kuai
2023-08-20 9:09 ` [PATCH -next v3 6/7] md: factor out a helper rdev_addable() " Yu Kuai
2023-08-21 23:22 ` Song Liu
2023-08-22 2:17 ` Yu Kuai [this message]
2023-08-23 3:04 ` Yu Kuai
2023-08-23 5:26 ` Song Liu
2023-08-23 8:37 ` Yu Kuai
2023-08-23 11:25 ` Song Liu
2023-08-24 1:16 ` Yu Kuai
2023-08-20 9:09 ` [PATCH -next v3 7/7] md: delay remove_and_add_spares() for read only array to md_start_sync() Yu Kuai
2023-08-23 3:24 ` Xiao Ni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7a82fb2-cf4b-2095-e813-84aed2418ff0@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mariusz.tkaczyk@linux.intel.com \
--cc=song@kernel.org \
--cc=xni@redhat.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).