Commit 55a48ad
md: Don't ignore read-only array in md_check_recovery()
Usually if the array is not read-write, md_check_recovery() won't
register new sync_thread in the first place. And if the array is
read-write and sync_thread is registered, md_set_readonly() will
unregister sync_thread before setting the array read-only. md/raid
follow this behavior hence there is no problem.
After commit f52f5c7 ("md: fix stopping sync thread"), following
hang can be triggered by test shell/integrity-caching.sh:
1) array is read-only. dm-raid update super block:
rs_update_sbs
ro = mddev->ro
mddev->ro = 0
-> set array read-write
md_update_sb
2) register new sync thread concurrently.
3) dm-raid set array back to read-only:
rs_update_sbs
mddev->ro = ro
4) stop the array:
raid_dtr
md_stop
stop_sync_thread
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_wakeup_thread_directly(mddev->sync_thread);
wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
5) sync thread done:
md_do_sync
set_bit(MD_RECOVERY_DONE, &mddev->recovery);
md_wakeup_thread(mddev->thread);
6) daemon thread can't unregister sync thread:
md_check_recovery
if (!md_is_rdwr(mddev) &&
!test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
return;
-> -> MD_RECOVERY_RUNNING can't be cleared, hence step 4 hang;
The root cause is that dm-raid manipulate 'mddev->ro' by itself,
however, dm-raid really should stop sync thread before setting the
array read-only. Unfortunately, I need to read more code before I
can refacter the handler of 'mddev->ro' in dm-raid, hence let's fix
the problem the easy way for now to prevent dm-raid regression.
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Closes: https://lore.kernel.org/all/9801e40-8ac7-e225-6a71-309dcf9dc9aa@redhat.com/
Fixes: ecbfb9f ("dm raid: add raid level takeover support")
Fixes: f52f5c7 ("md: fix stopping sync thread")
Cc: stable@vger.kernel.org # v6.7+
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240201092559.910982-3-yukuai1@huaweicloud.com1 parent 1baae05 commit 55a48ad
1 file changed
Lines changed: 18 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9449 | 9449 | | |
9450 | 9450 | | |
9451 | 9451 | | |
| 9452 | + | |
| 9453 | + | |
| 9454 | + | |
| 9455 | + | |
| 9456 | + | |
| 9457 | + | |
| 9458 | + | |
| 9459 | + | |
| 9460 | + | |
| 9461 | + | |
| 9462 | + | |
| 9463 | + | |
| 9464 | + | |
| 9465 | + | |
9452 | 9466 | | |
9453 | 9467 | | |
9454 | 9468 | | |
| |||
9486 | 9500 | | |
9487 | 9501 | | |
9488 | 9502 | | |
9489 | | - | |
| 9503 | + | |
| 9504 | + | |
9490 | 9505 | | |
9491 | 9506 | | |
9492 | 9507 | | |
| |||
9508 | 9523 | | |
9509 | 9524 | | |
9510 | 9525 | | |
9511 | | - | |
9512 | | - | |
| 9526 | + | |
9513 | 9527 | | |
9514 | 9528 | | |
9515 | 9529 | | |
| |||
9572 | 9586 | | |
9573 | 9587 | | |
9574 | 9588 | | |
9575 | | - | |
9576 | | - | |
9577 | | - | |
9578 | | - | |
9579 | | - | |
9580 | | - | |
9581 | | - | |
9582 | | - | |
9583 | | - | |
9584 | | - | |
| 9589 | + | |
9585 | 9590 | | |
9586 | 9591 | | |
9587 | 9592 | | |
| |||
0 commit comments