linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] md/raid5: don't allow concurrent reshape with recovery
@ 2023-05-29  3:10 Yu Kuai
  2023-05-29  6:44 ` Paul Menzel
  0 siblings, 1 reply; 3+ messages in thread
From: Yu Kuai @ 2023-05-29  3:10 UTC (permalink / raw)
  To: song; +Cc: linux-raid, linux-kernel, yukuai3, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

commit 0aecb06e2249 ("md/raid5: don't allow replacement while reshape
is in progress") fix that replacement can be set if reshape is
interrupted, which will cause that array can't be assemebled.

There is a similar on the other side, if recovery is interrupted, then
reshape can start, which will cause the same problem.

Fix the prblem by don't start reshape is recovery is still in progress.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/raid5.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 64865f9dd3f5..6db783ca71b7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8500,6 +8500,7 @@ static int raid5_start_reshape(struct mddev *mddev)
 	struct r5conf *conf = mddev->private;
 	struct md_rdev *rdev;
 	int spares = 0;
+	int i;
 	unsigned long flags;
 
 	if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
@@ -8511,6 +8512,13 @@ static int raid5_start_reshape(struct mddev *mddev)
 	if (has_failed(conf))
 		return -EINVAL;
 
+	/* raid5 can't handle concurrent reshape and recovery */
+	if (mddev->recovery_cp < MaxSector)
+		return -EBUSY;
+	for (i = 0; i < conf->raid_disks; i++)
+		if (rdev_mdlock_deref(mddev, conf->disks[i].replacement))
+			return -EBUSY;
+
 	rdev_for_each(rdev, mddev) {
 		if (!test_bit(In_sync, &rdev->flags)
 		    && !test_bit(Faulty, &rdev->flags))
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] md/raid5: don't allow concurrent reshape with recovery
  2023-05-29  3:10 [PATCH -next] md/raid5: don't allow concurrent reshape with recovery Yu Kuai
@ 2023-05-29  6:44 ` Paul Menzel
  2023-05-29 13:36   ` Yu Kuai
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Menzel @ 2023-05-29  6:44 UTC (permalink / raw)
  To: Yu Kuai; +Cc: song, linux-raid, linux-kernel, yukuai3, yi.zhang, yangerkun

Dear Yu,


Thank you for your patch. As always some minor commons, you can also ignore.

Am 29.05.23 um 05:10 schrieb Yu Kuai:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> commit 0aecb06e2249 ("md/raid5: don't allow replacement while reshape

I’d start with a capital letter: Commit …

> is in progress") fix that replacement can be set if reshape is

fixes

> interrupted, which will cause that array can't be assemebled.

assembled

> There is a similar on the other side, if recovery is interrupted, then

similar *problem*?

> reshape can start, which will cause the same problem.
> 
> Fix the prblem by don't start reshape is recovery is still in progress.

•  problem
•  … by not starting to reshape while recovery is still in progress

> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/raid5.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 64865f9dd3f5..6db783ca71b7 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -8500,6 +8500,7 @@ static int raid5_start_reshape(struct mddev *mddev)
>   	struct r5conf *conf = mddev->private;
>   	struct md_rdev *rdev;
>   	int spares = 0;
> +	int i;

It won’t make a difference for the code I believe, but as the count 
variable can’t be negative, I’d use `unsigned int`.

>   	unsigned long flags;
>   
>   	if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
> @@ -8511,6 +8512,13 @@ static int raid5_start_reshape(struct mddev *mddev)
>   	if (has_failed(conf))
>   		return -EINVAL;
>   
> +	/* raid5 can't handle concurrent reshape and recovery */
> +	if (mddev->recovery_cp < MaxSector)
> +		return -EBUSY;
> +	for (i = 0; i < conf->raid_disks; i++)
> +		if (rdev_mdlock_deref(mddev, conf->disks[i].replacement))
> +			return -EBUSY;
> +
>   	rdev_for_each(rdev, mddev) {
>   		if (!test_bit(In_sync, &rdev->flags)
>   		    && !test_bit(Faulty, &rdev->flags))


Kind regards,

Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] md/raid5: don't allow concurrent reshape with recovery
  2023-05-29  6:44 ` Paul Menzel
@ 2023-05-29 13:36   ` Yu Kuai
  0 siblings, 0 replies; 3+ messages in thread
From: Yu Kuai @ 2023-05-29 13:36 UTC (permalink / raw)
  To: Paul Menzel, Yu Kuai
  Cc: song, linux-raid, linux-kernel, yi.zhang, yangerkun, yukuai (C)

Hi,

在 2023/05/29 14:44, Paul Menzel 写道:
> Dear Yu,
> 
> 
> Thank you for your patch. As always some minor commons, you can also 
> ignore.

Thanks for there comments, I'll update them in v2 except that 'unsigned
int i'.

Thanks,
Kuai
> 
> Am 29.05.23 um 05:10 schrieb Yu Kuai:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> commit 0aecb06e2249 ("md/raid5: don't allow replacement while reshape
> 
> I’d start with a capital letter: Commit …
> 
>> is in progress") fix that replacement can be set if reshape is
> 
> fixes
> 
>> interrupted, which will cause that array can't be assemebled.
> 
> assembled
> 
>> There is a similar on the other side, if recovery is interrupted, then
> 
> similar *problem*?
> 
>> reshape can start, which will cause the same problem.
>>
>> Fix the prblem by don't start reshape is recovery is still in progress.
> 
> •  problem
> •  … by not starting to reshape while recovery is still in progress
> 
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   drivers/md/raid5.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
>> index 64865f9dd3f5..6db783ca71b7 100644
>> --- a/drivers/md/raid5.c
>> +++ b/drivers/md/raid5.c
>> @@ -8500,6 +8500,7 @@ static int raid5_start_reshape(struct mddev *mddev)
>>       struct r5conf *conf = mddev->private;
>>       struct md_rdev *rdev;
>>       int spares = 0;
>> +    int i;
> 
> It won’t make a difference for the code I believe, but as the count 
> variable can’t be negative, I’d use `unsigned int`.
> 
>>       unsigned long flags;
>>       if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
>> @@ -8511,6 +8512,13 @@ static int raid5_start_reshape(struct mddev 
>> *mddev)
>>       if (has_failed(conf))
>>           return -EINVAL;
>> +    /* raid5 can't handle concurrent reshape and recovery */
>> +    if (mddev->recovery_cp < MaxSector)
>> +        return -EBUSY;
>> +    for (i = 0; i < conf->raid_disks; i++)
>> +        if (rdev_mdlock_deref(mddev, conf->disks[i].replacement))
>> +            return -EBUSY;
>> +
>>       rdev_for_each(rdev, mddev) {
>>           if (!test_bit(In_sync, &rdev->flags)
>>               && !test_bit(Faulty, &rdev->flags))
> 
> 
> Kind regards,
> 
> Paul
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-29 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29  3:10 [PATCH -next] md/raid5: don't allow concurrent reshape with recovery Yu Kuai
2023-05-29  6:44 ` Paul Menzel
2023-05-29 13:36   ` Yu Kuai

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