Skip to contentSkip to conversation

mdadm/Incremental: wait a while before removing a member

PATCH Superseded Xiao Ni 1 participant 1 message Oct 17, 2025 MD RAID

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xiao Ni

author
#0 lore raw

PATCH 1/1 mdadm/Incremental: wait a while before removing a member

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.

---
 Incremental.c | 6 ++++++
 1 file changed, 6 insertions(+)
Incremental.c +6 -0
index ba3810e6157f..d04168121199 100644
@@ -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);
 
Signature · 1 line
2.32.0 (Apple Git-132)