[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW6ru-Chofq8ki6Xh9U0utH6+_mo0dd3Ty8fZPHGtJ1xvQ@mail.gmail.com>
Date: Wed, 4 Oct 2023 21:00:07 -0700
From: Song Liu <song@...nel.org>
To: Yu Kuai <yukuai1@...weicloud.com>
Cc: xni@...hat.com, agk@...hat.com, snitzer@...nel.org,
dm-devel@...hat.com, linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org, yi.zhang@...wei.com,
yangerkun@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH -next v3 03/25] md: add new helpers to suspend/resume array
On Wed, Oct 4, 2023 at 7:59 PM Yu Kuai <yukuai1@...weicloud.com> wrote:
>
> Hi,
>
> 在 2023/09/29 2:45, Song Liu 写道:
> > On Wed, Sep 27, 2023 at 11:22 PM Yu Kuai <yukuai1@...weicloud.com> wrote:
> >>
> >> From: Yu Kuai <yukuai3@...wei.com>
> >>
> >> Advantages for new apis:
> >> - reconfig_mutex is not required;
> >> - the weird logical that suspend array hold 'reconfig_mutex' for
> >> mddev_check_recovery() to update superblock is not needed;
> >> - the specail handling, 'pers->prepare_suspend', for raid456 is not
> >> needed;
> >> - It's safe to be called at any time once mddev is allocated, and it's
> >> designed to be used from slow path where array configuration is changed;
> >> - the new helpers is designed to be called before mddev_lock(), hence
> >> it support to be interrupted by user as well.
> >>
> >> Signed-off-by: Yu Kuai <yukuai3@...wei.com>
> >> ---
> >> drivers/md/md.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++-
> >> drivers/md/md.h | 3 ++
> >> 2 files changed, 103 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/md/md.c b/drivers/md/md.c
> >> index e460b380143d..a075d03d03d3 100644
> >> --- a/drivers/md/md.c
> >> +++ b/drivers/md/md.c
> >> @@ -443,12 +443,22 @@ void mddev_suspend(struct mddev *mddev)
> >> lockdep_is_held(&mddev->reconfig_mutex));
> >>
> >> WARN_ON_ONCE(thread && current == thread->tsk);
> >> - if (mddev->suspended++)
> >> +
> >> + /* can't concurrent with __mddev_suspend() and __mddev_resume() */
> >> + mutex_lock(&mddev->suspend_mutex);
> >> + if (mddev->suspended++) {
> >> + mutex_unlock(&mddev->suspend_mutex);
> >> return;
> >
> > Can we make mddev->suspended atomic_t, and use atomic_inc_return()
> > here?
>
> 'suspend_mutex' is needed, because concurrent caller of
> mddev_suspend() shound be ordered, they need to wait for the first
> mddev_suspend() to be done.
>
> Updating suspended is protected by 'suspend_mutex' in the new api, so I
> think it's not necessary to use atomic, WRITE/READ_ONCE() should be
> enough.
Thanks for the explanation.
Song
Powered by blists - more mailing lists