diff mbox series

[v2,2/7] md: don't wait faulty rdev in md_wait_for_blocked_rdev()

Message ID 20241011011630.2002803-3-yukuai1@huaweicloud.com (mailing list archive)
State Accepted
Headers show
Series md: enhance faulty checking for blocked handling | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_12-PR fail PR summary
mdraidci/vmtest-md-6_12-VM_Test-0 fail Logs for per-patch-testing
mdraidci/vmtest-md-6_13-PR success PR summary
mdraidci/vmtest-md-6_13-VM_Test-0 success Logs for per-patch-testing

Commit Message

Yu Kuai Oct. 11, 2024, 1:16 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

md_wait_for_blocked_rdev() is called for write IO while rdev is
blocked, howerver, rdev can be faulty after choosing this rdev to write,
and faulty rdev should never be accessed anymore, hence there is no point
to wait for faulty rdev to be unblocked.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/md.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Yu Kuai Oct. 30, 2024, 1:22 a.m. UTC | #1
Hi,

在 2024/10/11 9:16, Yu Kuai 写道:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> md_wait_for_blocked_rdev() is called for write IO while rdev is
> blocked, howerver, rdev can be faulty after choosing this rdev to write,
> and faulty rdev should never be accessed anymore, hence there is no point
> to wait for faulty rdev to be unblocked.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/md.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 179ee4afe937..37d1469bfc82 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -9762,9 +9762,7 @@ EXPORT_SYMBOL(md_reap_sync_thread);
>   void md_wait_for_blocked_rdev(struct md_rdev *rdev, struct mddev *mddev)
>   {
>   	sysfs_notify_dirent_safe(rdev->sysfs_state);
> -	wait_event_timeout(rdev->blocked_wait,
> -			   !test_bit(Blocked, &rdev->flags) &&
> -			   !test_bit(BlockedBadBlocks, &rdev->flags),
> +	wait_event_timeout(rdev->blocked_wait, rdev_blocked(rdev),

Just found that there is a stupid mistake that I should use:

!rdev_blocked(rdev)

Tests can't find this mistake because wait_event_timeout() is used,
and caller will break out if rdev is unblocked.

Song, since this is still is md-6.13. Do you want to to send a fix, or
update this version?

Thanks,
Kuai

>   			   msecs_to_jiffies(5000));
>   	rdev_dec_pending(rdev, mddev);
>   }
>
Song Liu Oct. 30, 2024, 6:28 a.m. UTC | #2
On Tue, Oct 29, 2024 at 6:22 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> Hi,
>
> 在 2024/10/11 9:16, Yu Kuai 写道:
> > From: Yu Kuai <yukuai3@huawei.com>
> >
> > md_wait_for_blocked_rdev() is called for write IO while rdev is
> > blocked, howerver, rdev can be faulty after choosing this rdev to write,
> > and faulty rdev should never be accessed anymore, hence there is no point
> > to wait for faulty rdev to be unblocked.
> >
> > Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> > ---
> >   drivers/md/md.c | 4 +---
> >   1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/md/md.c b/drivers/md/md.c
> > index 179ee4afe937..37d1469bfc82 100644
> > --- a/drivers/md/md.c
> > +++ b/drivers/md/md.c
> > @@ -9762,9 +9762,7 @@ EXPORT_SYMBOL(md_reap_sync_thread);
> >   void md_wait_for_blocked_rdev(struct md_rdev *rdev, struct mddev *mddev)
> >   {
> >       sysfs_notify_dirent_safe(rdev->sysfs_state);
> > -     wait_event_timeout(rdev->blocked_wait,
> > -                        !test_bit(Blocked, &rdev->flags) &&
> > -                        !test_bit(BlockedBadBlocks, &rdev->flags),
> > +     wait_event_timeout(rdev->blocked_wait, rdev_blocked(rdev),
>
> Just found that there is a stupid mistake that I should use:
>
> !rdev_blocked(rdev)
>
> Tests can't find this mistake because wait_event_timeout() is used,
> and caller will break out if rdev is unblocked.
>
> Song, since this is still is md-6.13. Do you want to to send a fix, or
> update this version?

Please send a fixed version (the whole set). I will update the branch.

Thanks,
Song
diff mbox series

Patch

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 179ee4afe937..37d1469bfc82 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9762,9 +9762,7 @@  EXPORT_SYMBOL(md_reap_sync_thread);
 void md_wait_for_blocked_rdev(struct md_rdev *rdev, struct mddev *mddev)
 {
 	sysfs_notify_dirent_safe(rdev->sysfs_state);
-	wait_event_timeout(rdev->blocked_wait,
-			   !test_bit(Blocked, &rdev->flags) &&
-			   !test_bit(BlockedBadBlocks, &rdev->flags),
+	wait_event_timeout(rdev->blocked_wait, rdev_blocked(rdev),
 			   msecs_to_jiffies(5000));
 	rdev_dec_pending(rdev, mddev);
 }