dm-raid: delay flushing event_work() after reconfig_mutex is released
authorYu Kuai <yukuai3@huawei.com>
Fri, 24 Nov 2023 07:59:53 +0000 (15:59 +0800)
committerMike Snitzer <snitzer@kernel.org>
Mon, 18 Dec 2023 18:05:21 +0000 (13:05 -0500)
commitdb29d79b34d9593179de5f868be45c650923e7b4
tree0594db7328418a993dd1a9aff8120cda9ade4887
parentceb6a6f023fd3e8b07761ed900352ef574010bcb
dm-raid: delay flushing event_work() after reconfig_mutex is released

After commit db5e653d7c9f ("md: delay choosing sync action to
md_start_sync()"), md_start_sync() will hold 'reconfig_mutex', however,
in order to make sure event_work is done, __md_stop() will flush
workqueue with reconfig_mutex grabbed, hence if sync_work is still
pending, deadlock will be triggered.

Fortunately, former pacthes to fix stopping sync_thread already make sure
all sync_work is done already, hence such deadlock is not possible
anymore. However, in order not to cause confusions for people by this
implicit dependency, delay flushing event_work to dm-raid where
'reconfig_mutex' is not held, and add some comments to emphasize that
the workqueue can't be flushed with 'reconfig_mutex'.

Fixes: db5e653d7c9f ("md: delay choosing sync action to md_start_sync()")
Depends-on: f52f5c71f3d4 ("md: fix stopping sync thread")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-raid.c
drivers/md/md.c