From: Yu Kuai <[email protected]>
This patchset is minor changes that I found by code review while I'm
working on synchronize io and array configuration. I'm planing to
refactor mddev_suspend() from:
mddev_lock
// array configuration
mddev_unlock
and:
mddev_lock
mddev_suspend
// array configuration
mddev_resume
mddev_unlock
to:
mddev_suspend
mddev_lock
// array configuration
mddev_unlock
mddev_resume
Yu Kuai (2):
md: don't quiesce in mddev_suspend()
md: restore 'noio_flag' for the last mddev_resume()
drivers/md/md.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--
2.39.2
From: Yu Kuai <[email protected]>
Some levels doesn't implement "pers->quiesce", for example
raid0_quiesce() is empty, and now that all levels will drop 'active_io'
until io is done, wait for 'active_io' to be 0 is enough to make sure all
normal io is done, and percpu_ref_kill() for 'active_io' will make sure
no new normal io can be dispatched. There is no need to call
"pers->quiesce" anymore from mddev_suspend().
Signed-off-by: Yu Kuai <[email protected]>
---
drivers/md/md.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index abb616720393..962dacfd98cf 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -453,7 +453,6 @@ void mddev_suspend(struct mddev *mddev)
mddev->pers->prepare_suspend(mddev);
wait_event(mddev->sb_wait, percpu_ref_is_zero(&mddev->active_io));
- mddev->pers->quiesce(mddev, 1);
clear_bit_unlock(MD_ALLOW_SB_UPDATE, &mddev->flags);
wait_event(mddev->sb_wait, !test_bit(MD_UPDATING_SB, &mddev->flags));
@@ -472,7 +471,6 @@ void mddev_resume(struct mddev *mddev)
return;
percpu_ref_resurrect(&mddev->active_io);
wake_up(&mddev->sb_wait);
- mddev->pers->quiesce(mddev, 0);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
md_wakeup_thread(mddev->thread);
--
2.39.2
Hi,
?? 2023/06/28 9:29, Yu Kuai д??:
> From: Yu Kuai <[email protected]>
>
> Some levels doesn't implement "pers->quiesce", for example
> raid0_quiesce() is empty, and now that all levels will drop 'active_io'
> until io is done, wait for 'active_io' to be 0 is enough to make sure all
> normal io is done, and percpu_ref_kill() for 'active_io' will make sure
> no new normal io can be dispatched. There is no need to call
> "pers->quiesce" anymore from mddev_suspend().
Just found that this patch actually prevent null_ptr_deref in some cases
that "pers->quiesce" is NULl for some personalities, and caller of
mddev_suspend() doesn't check this. For example, suspend_lo_store()
checks "pers->quiesce" is not NULL before calling mddev_suspend(), while
suspend_hi_store() doesn't.
Thanks,
Kuai
>
> Signed-off-by: Yu Kuai <[email protected]>
> ---
> drivers/md/md.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index abb616720393..962dacfd98cf 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -453,7 +453,6 @@ void mddev_suspend(struct mddev *mddev)
> mddev->pers->prepare_suspend(mddev);
>
> wait_event(mddev->sb_wait, percpu_ref_is_zero(&mddev->active_io));
> - mddev->pers->quiesce(mddev, 1);
> clear_bit_unlock(MD_ALLOW_SB_UPDATE, &mddev->flags);
> wait_event(mddev->sb_wait, !test_bit(MD_UPDATING_SB, &mddev->flags));
>
> @@ -472,7 +471,6 @@ void mddev_resume(struct mddev *mddev)
> return;
> percpu_ref_resurrect(&mddev->active_io);
> wake_up(&mddev->sb_wait);
> - mddev->pers->quiesce(mddev, 0);
>
> set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
> md_wakeup_thread(mddev->thread);
>
Hi,
?? 2023/06/28 9:29, Yu Kuai д??:
> From: Yu Kuai <[email protected]>
>
> This patchset is minor changes that I found by code review while I'm
> working on synchronize io and array configuration. I'm planing to
> refactor mddev_suspend() from:
>
> mddev_lock
> // array configuration
> mddev_unlock
>
> and:
>
> mddev_lock
> mddev_suspend
> // array configuration
> mddev_resume
> mddev_unlock
>
> to:
>
> mddev_suspend
> mddev_lock
> // array configuration
> mddev_unlock
> mddev_resume
>
Friendly ping ...
Thanks,
Kuai
> Yu Kuai (2):
> md: don't quiesce in mddev_suspend()
> md: restore 'noio_flag' for the last mddev_resume()
>
> drivers/md/md.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
On Fri, Jul 7, 2023 at 9:25 AM Yu Kuai <[email protected]> wrote:
>
> Hi,
>
> 在 2023/06/28 9:29, Yu Kuai 写道:
> > From: Yu Kuai <[email protected]>
> >
> > This patchset is minor changes that I found by code review while I'm
> > working on synchronize io and array configuration. I'm planing to
> > refactor mddev_suspend() from:
> >
> > mddev_lock
> > // array configuration
> > mddev_unlock
> >
> > and:
> >
> > mddev_lock
> > mddev_suspend
> > // array configuration
> > mddev_resume
> > mddev_unlock
> >
> > to:
> >
> > mddev_suspend
> > mddev_lock
> > // array configuration
> > mddev_unlock
> > mddev_resume
> >
>
> Friendly ping ...
Applied to md-next. Thanks!
Song
On Wed, Jun 28, 2023 at 2:29 PM Yu Kuai <[email protected]> wrote:
>
> Hi,
>
> 在 2023/06/28 9:29, Yu Kuai 写道:
> > From: Yu Kuai <[email protected]>
> >
> > Some levels doesn't implement "pers->quiesce", for example
> > raid0_quiesce() is empty, and now that all levels will drop 'active_io'
> > until io is done, wait for 'active_io' to be 0 is enough to make sure all
> > normal io is done, and percpu_ref_kill() for 'active_io' will make sure
> > no new normal io can be dispatched. There is no need to call
> > "pers->quiesce" anymore from mddev_suspend().
>
> Just found that this patch actually prevent null_ptr_deref in some cases
> that "pers->quiesce" is NULl for some personalities, and caller of
> mddev_suspend() doesn't check this. For example, suspend_lo_store()
> checks "pers->quiesce" is not NULL before calling mddev_suspend(), while
> suspend_hi_store() doesn't.
Let's refactor the code so that suspend_lo_store() and suspend_hi_store()
share code for this logic.
Thanks,
Song