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 <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231010151958.145896-18-yukuai1@huaweicloud.com
This commit is contained in:
parent
b42cd7b3a2
commit
bc08041b32
1 changed files with 8 additions and 3 deletions
|
@ -9417,7 +9417,12 @@ static void md_start_sync(struct work_struct *ws)
|
||||||
{
|
{
|
||||||
struct mddev *mddev = container_of(ws, struct mddev, sync_work);
|
struct mddev *mddev = container_of(ws, struct mddev, sync_work);
|
||||||
int spares = 0;
|
int spares = 0;
|
||||||
|
bool suspend = false;
|
||||||
|
|
||||||
|
if (md_spares_need_change(mddev))
|
||||||
|
suspend = true;
|
||||||
|
|
||||||
|
suspend ? mddev_suspend_and_lock_nointr(mddev) :
|
||||||
mddev_lock_nointr(mddev);
|
mddev_lock_nointr(mddev);
|
||||||
|
|
||||||
if (!md_is_rdwr(mddev)) {
|
if (!md_is_rdwr(mddev)) {
|
||||||
|
@ -9454,7 +9459,7 @@ static void md_start_sync(struct work_struct *ws)
|
||||||
goto not_running;
|
goto not_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
mddev_unlock(mddev);
|
suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
|
||||||
md_wakeup_thread(mddev->sync_thread);
|
md_wakeup_thread(mddev->sync_thread);
|
||||||
sysfs_notify_dirent_safe(mddev->sysfs_action);
|
sysfs_notify_dirent_safe(mddev->sysfs_action);
|
||||||
md_new_event();
|
md_new_event();
|
||||||
|
@ -9466,7 +9471,7 @@ not_running:
|
||||||
clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
|
clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
|
||||||
clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
|
clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
|
||||||
clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
|
clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
|
||||||
mddev_unlock(mddev);
|
suspend ? mddev_unlock_and_resume(mddev) : mddev_unlock(mddev);
|
||||||
|
|
||||||
wake_up(&resync_wait);
|
wake_up(&resync_wait);
|
||||||
if (test_and_clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery) &&
|
if (test_and_clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery) &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue