linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: linux-raid@vger.kernel.org
Cc: mtkaczyk@kernel.org, ncroxon@redhat.com
Subject: [PATCH 1/1] mdadm/Incremental: wait a while before removing a member
Date: Fri, 17 Oct 2025 16:30:29 +0800	[thread overview]
Message-ID: <20251017083029.53138-1-xni@redhat.com> (raw)

We encountered a regression that member disk can't be removed in
incremental remove mode:
mdadm -If /dev/loop0
mdadm: Cannot remove member device loop0 from md127

It doesn't allow to remove a member if sync thread is running. mdadm -If
sets member disk faulty first, then it removes the disk. If sync thread
is running, it will be interrupted by setting a member faulty. But the sync
thread hasn't been reapped. So it needs to wait a while to let kernel to
reap sync thread.

Signed-off-by: Xiao Ni <xni@redhat.com>
---
 Incremental.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Incremental.c b/Incremental.c
index ba3810e6157f..d04168121199 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1793,6 +1793,12 @@ int Incremental_remove(char *devname, char *id_path, int verbose)
 	if (rv && verbose >= 0)
 		pr_err("Cannot fail member device %s in array %s.\n", devnm, ent->devnm);
 
+	/*
+	 * If resync/recovery is running, sync thread is interrupted by setting member faulty.
+	 * And it needs to wait sometime to let kernel to reap sync thread. If not, it will
+	 * fail to remove it.
+	 */
+	sleep_for(5, 0, true);
 	if (rv == MDADM_STATUS_SUCCESS)
 		rv = sysfs_set_memb_state(ent->devnm, devnm, MEMB_STATE_REMOVE);
 
-- 
2.32.0 (Apple Git-132)


                 reply	other threads:[~2025-10-17  8:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251017083029.53138-1-xni@redhat.com \
    --to=xni@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mtkaczyk@kernel.org \
    --cc=ncroxon@redhat.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;
as well as URLs for NNTP newsgroup(s).