]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
md: allow removing faulty rdev during resync
authorZheng Qixing <zhengqixing@huawei.com>
Mon, 7 Jul 2025 07:54:12 +0000 (15:54 +0800)
committerYu Kuai <yukuai3@huawei.com>
Sat, 12 Jul 2025 09:55:20 +0000 (17:55 +0800)
commitc0ffeb648000acdc932da7a9d33fd65e9263c54c
tree6910d3484b0e0f4649882bb8df77722dd1cec288
parent3ec8db61e7852b0d0637483c8fd249533d701bff
md: allow removing faulty rdev during resync

During RAID resync, faulty rdev cannot be removed and will result in
"Device or resource busy" error when attempting hot removal.

Reproduction steps:
  mdadm -Cv /dev/md0 -l1 -n3 -e1.2 /dev/sd{b..d}
  mdadm /dev/md0 -f /dev/sdb
  mdadm /dev/md0 -r /dev/sdb
  -> mdadm: hot remove failed for /dev/sdb: Device or resource busy

After commit 4b10a3bc67c1 ("md: ensure resync is prioritized over
recovery"), when a device becomes faulty during resync, the
md_choose_sync_action() function returns early without calling
remove_and_add_spares(), preventing faulty device removal.

This patch extracts a helper function remove_spares() to support
removing faulty devices during RAID resync operations.

Fixes: 4b10a3bc67c1 ("md: ensure resync is prioritized over recovery")
Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
Reviewed-by: Li Nan <linan122@huawei.com>
Link: https://lore.kernel.org/linux-raid/20250707075412.150301-1-zhengqixing@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
drivers/md/md.c