Skip to content

Commit bc08041

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: suspend array in md_start_sync() if array need reconfiguration
So that io won't concurrent with array reconfiguration, and it's safe to suspend the array directly because normal io won't rely on md_start_sync(). Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b42cd7b commit bc08041

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/md/md.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9417,8 +9417,13 @@ static void md_start_sync(struct work_struct *ws)
94179417
{
94189418
struct mddev *mddev = container_of(ws, struct mddev, sync_work);
94199419
int spares = 0;
9420+
bool suspend = false;
94209421

9421-
mddev_lock_nointr(mddev);
9422+
if (md_spares_need_change(mddev))
9423+
suspend = true;
9424+
9425+
suspend ? mddev_suspend_and_lock_nointr(mddev) :
9426+
mddev_lock_nointr(mddev);
94229427

94239428
if (!md_is_rdwr(mddev)) {
94249429
/*
@@ -9454,7 +9459,7 @@ static void md_start_sync(struct work_struct *ws)
94549459
goto not_running;
94559460
}
94569461

9457-
mddev_unlock(mddev);
9462+
suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
94589463
md_wakeup_thread(mddev->sync_thread);
94599464
sysfs_notify_dirent_safe(mddev->sysfs_action);
94609465
md_new_event();
@@ -9466,7 +9471,7 @@ static void md_start_sync(struct work_struct *ws)
94669471
clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
94679472
clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
94689473
clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
9469-
mddev_unlock(mddev);
9474+
suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
94709475

94719476
wake_up(&resync_wait);
94729477
if (test_and_clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery) &&

0 commit comments

Comments
 (0)