mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: dannyshih <dannyshih@synology.com>
To: song@kernel.org, yukuai@fnnas.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	dannyshih@synology.com
Subject: [PATCH] md: suspend array while updating raid1 raid_disks via sysfs
Date: Thu, 18 Dec 2025 17:06:56 +0800	[thread overview]
Message-ID: <20251218090656.10278-1-dannyshih@synology.com> (raw)

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.

* 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);
 
 	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 =
-- 
2.17.1


Disclaimer: The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.

             reply	other threads:[~2025-12-18  9:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  9:06 dannyshih [this message]
2025-12-25  8:19 ` Yu Kuai
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=20251218090656.10278-1-dannyshih@synology.com \
    --to=dannyshih@synology.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai@fnnas.com \
    /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®