Skip to content

Commit 82ec0ae

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: Make sure md_do_sync() will set MD_RECOVERY_DONE
stop_sync_thread() will interrupt md_do_sync(), and md_do_sync() must set MD_RECOVERY_DONE, so that follow up md_check_recovery() will unregister sync_thread, clear MD_RECOVERY_RUNNING and wake up stop_sync_thread(). If MD_RECOVERY_WAIT is set or the array is read-only, md_do_sync() will return without setting MD_RECOVERY_DONE, and after commit f52f5c7 ("md: fix stopping sync thread"), dm-raid switch from md_reap_sync_thread() to stop_sync_thread() to unregister sync_thread from md_stop() and md_stop_writes(), causing the test shell/lvconvert-raid-reshape.sh hang. We shouldn't switch back to md_reap_sync_thread() because it's problematic in the first place. Fix the problem by making sure md_do_sync() will set MD_RECOVERY_DONE. Reported-by: Mikulas Patocka <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: d5d885f ("md: introduce new personality funciton start()") Fixes: 5fd6c1d ("[PATCH] md: allow checkpoint of recovery with version-1 superblock") Fixes: f52f5c7 ("md: fix stopping sync thread") Cc: [email protected] # v6.7+ Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 55a48ad commit 82ec0ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/md/md.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8792,12 +8792,16 @@ void md_do_sync(struct md_thread *thread)
87928792
int ret;
87938793

87948794
/* just incase thread restarts... */
8795-
if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
8796-
test_bit(MD_RECOVERY_WAIT, &mddev->recovery))
8795+
if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
87978796
return;
8798-
if (!md_is_rdwr(mddev)) {/* never try to sync a read-only array */
8797+
8798+
if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
8799+
goto skip;
8800+
8801+
if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) ||
8802+
!md_is_rdwr(mddev)) {/* never try to sync a read-only array */
87998803
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
8800-
return;
8804+
goto skip;
88018805
}
88028806

88038807
if (mddev_is_clustered(mddev)) {

0 commit comments

Comments
 (0)