* [PATCH v6 0/2] md: fix sync_work vs array teardown races
@ 2026-11-26 8:08 Li Youhong
2026-11-26 8:23 ` Li Youhong
0 siblings, 1 reply; 2+ messages in thread
From: Li Youhong @ 2026-11-26 8:08 UTC (permalink / raw)
To: song, yukuai; +Cc: magiclinan, xiao, linux-raid, linux-kernel, Li Youhong
From: Li Youhong <liyouhong@kylinos.cn>
dm-raid tears down arrays via md_stop(), which cleared mddev->pers
without waiting for previously queued sync_work. That work could
then call remove_spares() with pers == NULL, or keep using mddev
after raid_dtr() frees it.
do_md_stop()/md_stop_writes() already call stop_sync_thread() before
teardown. md_stop() needs the same wait, plus a few related holes
around work_busy(), MD_RECOVERY_FROZEN on the read-only path, and
event_work on the raid_ctr() error path.
This series splits the previous combined fix so the work_pending ->
work_busy change can land on its own.
Li Youhong (2):
md: use work_busy() to flush sync_work in stop_sync_thread()
md: fix sync_work vs array teardown races
drivers/md/dm-raid.c | 7 +++++++
drivers/md/md.c | 39 +++++++++++++++++++++++++++++----------
2 files changed, 36 insertions(+), 10 deletions(-)
---
v6:
- Split into two patches per review:
1/2: only replace work_pending() with work_busy() when flushing
sync_work in stop_sync_thread(); Fixes: f52f5c71f3d4.
2/2: remaining changes (md_stop wait, idle early-return gated by
work_busy(), INTR only when RUNNING, RO FROZEN check,
flush event_work on raid_ctr() error path).
- v5: https://lore.kernel.org/linux-raid/20261112013523.120428-1-dayou5941@163.com/
v5:
- Restore idle early-return in stop_sync_thread() gated by work_busy(),
so locked callers keep reconfig_mutex and do not race with do_md_run().
- Flush event_work before raid_set_free() on the raid_ctr error path
(md_stop() may drop the mutex and let md_reap queue it).
- v4: https://lore.kernel.org/linux-raid/20261111015027.4029184-1-dayou5941@163.com
v4:
- Always flush_work(&sync_work) in stop_sync_thread(); do not delay
clearing MD_RECOVERY_RUNNING (that can drop MD_RECOVERY_NEEDED via
md_check_recovery, and does not cover the successful sync_thread
registration path).
- v3: https://lore.kernel.org/linux-raid/20261110063045.912703-1-dayou5941@163.com
v3:
- Honour MD_RECOVERY_FROZEN before queueing sync_work on the
read-only md_check_recovery() path.
- (superseded) delayed MD_RECOVERY_RUNNING clear on not_running.
- v2: https://lore.kernel.org/linux-raid/20261109023055.2164333-1-dayou5941@163.com
v2:
- Drop the pers NULL check in md_start_sync().
- Call stop_sync_thread() from md_stop() before clearing pers,
matching do_md_stop()/md_stop_writes().
- v1: https://lore.kernel.org/linux-raid/20261106083543.249267-1-dayou5941@163.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v6 0/2] md: fix sync_work vs array teardown races
2026-11-26 8:08 [PATCH v6 0/2] md: fix sync_work vs array teardown races Li Youhong
@ 2026-11-26 8:23 ` Li Youhong
0 siblings, 0 replies; 2+ messages in thread
From: Li Youhong @ 2026-11-26 8:23 UTC (permalink / raw)
To: linux-raid; +Cc: linux-kernel, liyouhong, magiclinan, song, xiao, yukuai
Hi,
Sorry, this series was not sent correctly (the patches were not
posted as one continuous, dependent series). Please ignore it.
I will resend a corrected v6 shortly.
Thanks,
Li Youhong
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 8:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 8:08 [PATCH v6 0/2] md: fix sync_work vs array teardown races Li Youhong
2026-11-26 8:23 ` Li Youhong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®