From: "Yu Kuai" <yukuai@fnnas.com>
To: "dannyshih" <dannyshih@synology.com>, <song@kernel.org>
Cc: <linux-raid@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yukuai@fnnas.com>
Subject: Re: [PATCH] md: suspend array while updating raid1 raid_disks via sysfs
Date: Thu, 25 Dec 2025 16:19:46 +0800 [thread overview]
Message-ID: <75dd6e7d-383e-44c0-978a-42c286a3d9c3@fnnas.com> (raw)
In-Reply-To: <20251218090656.10278-1-dannyshih@synology.com>
Hi,
在 2025/12/18 17:06, dannyshih 写道:
> From: FengWei Shih <dannyshih@synology.com>
>
> When an I/O error occurs, the corresponding r1bio might be queued during
> raid1_reshape() and not released. Leads to r1bio release with wrong
> raid_disks.
Please be more specific about the problem, mempool_destroy() will warn about
object still in use, and free r1bio with updated conf->raid_disks will cause
problem like memory oob.
>
> * raid1_reshape() calls freeze_array(), which only waits for r1bios be
> queued or released.
>
> Since only normal I/O might be queued while an I/O error occurs, suspending
> the array avoids this issue.
>
> Signed-off-by: FengWei Shih <dannyshih@synology.com>
> ---
> drivers/md/md.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e5922a682953..6424652bce6e 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -4402,12 +4402,13 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
> {
> unsigned int n;
> int err;
> + bool need_suspend = (mddev->pers && mddev->level == 1);
Perhaps just suspend the array unconditionally, this will make sense.
>
> err = kstrtouint(buf, 10, &n);
> if (err < 0)
> return err;
>
> - err = mddev_lock(mddev);
> + err = need_suspend ? mddev_suspend_and_lock(mddev) : mddev_lock(mddev);
> if (err)
> return err;
> if (mddev->pers)
> @@ -4432,7 +4433,7 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
> } else
> mddev->raid_disks = n;
> out_unlock:
> - mddev_unlock(mddev);
> + need_suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
> return err ? err : len;
> }
> static struct md_sysfs_entry md_raid_disks =
--
Thansk,
Kuai
next prev parent reply other threads:[~2025-12-25 8:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 9:06 dannyshih
2025-12-25 8:19 ` Yu Kuai [this message]
2025-12-26 4:45 ` FengWei Shih
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=75dd6e7d-383e-44c0-978a-42c286a3d9c3@fnnas.com \
--to=yukuai@fnnas.com \
--cc=dannyshih@synology.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
/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
all inboxes | Powered by JetHome®