Skip to content

Commit 90f5f7a

Browse files
hreineckeneilbrown
authored andcommitted
md: Wait for md_check_recovery before attempting device removal.
When a device has failed, it needs to be removed from the personality module before it can be removed from the array as a whole. The first step is performed by md_check_recovery() which is called from the raid management thread. So when a HOT_REMOVE ioctl arrives, wait briefly for md_check_recovery to have run. This increases the chance that the ioctl will succeed. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Neil Brown <nfbrown@suse.de>
1 parent 3f6bbd3 commit 90f5f7a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/md/md.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6405,6 +6405,12 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
64056405
/* need to ensure md_delayed_delete() has completed */
64066406
flush_workqueue(md_misc_wq);
64076407

6408+
if (cmd == HOT_REMOVE_DISK)
6409+
/* need to ensure recovery thread has run */
6410+
wait_event_interruptible_timeout(mddev->sb_wait,
6411+
!test_bit(MD_RECOVERY_NEEDED,
6412+
&mddev->flags),
6413+
msecs_to_jiffies(5000));
64086414
err = mddev_lock(mddev);
64096415
if (err) {
64106416
printk(KERN_INFO
@@ -7892,6 +7898,8 @@ void md_check_recovery(struct mddev *mddev)
78927898
md_new_event(mddev);
78937899
}
78947900
unlock:
7901+
wake_up(&mddev->sb_wait);
7902+
78957903
if (!mddev->sync_thread) {
78967904
clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
78977905
if (test_and_clear_bit(MD_RECOVERY_RECOVER,

0 commit comments

Comments
 (0)