mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
md/raid5-cache: fix a deadlock in r5l_exit_log()
[ Upstream commita705b11b35] Commitb13015af94("md/raid5-cache: Clear conf->log after finishing work") introduce a new problem: // caller hold reconfig_mutex r5l_exit_log flush_work(&log->disable_writeback_work) r5c_disable_writeback_async wait_event /* * conf->log is not NULL, and mddev_trylock() * will fail, wait_event() can never pass. */ conf->log = NULL Fix this problem by setting 'config->log' to NULL before wake_up() as it used to be, so that wait_event() from r5c_disable_writeback_async() can exist. In the meantime, move forward md_unregister_thread() so that null-ptr-deref this commit fixed can still be fixed. Fixes:b13015af94("md/raid5-cache: Clear conf->log after finishing work") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20230708091727.1417894-1-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
26bf790b8e
commit
ac9e103f28
@@ -3166,12 +3166,15 @@ void r5l_exit_log(struct r5conf *conf)
|
|||||||
{
|
{
|
||||||
struct r5l_log *log = conf->log;
|
struct r5l_log *log = conf->log;
|
||||||
|
|
||||||
/* Ensure disable_writeback_work wakes up and exits */
|
|
||||||
wake_up(&conf->mddev->sb_wait);
|
|
||||||
flush_work(&log->disable_writeback_work);
|
|
||||||
md_unregister_thread(&log->reclaim_thread);
|
md_unregister_thread(&log->reclaim_thread);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 'reconfig_mutex' is held by caller, set 'confg->log' to NULL to
|
||||||
|
* ensure disable_writeback_work wakes up and exits.
|
||||||
|
*/
|
||||||
conf->log = NULL;
|
conf->log = NULL;
|
||||||
|
wake_up(&conf->mddev->sb_wait);
|
||||||
|
flush_work(&log->disable_writeback_work);
|
||||||
|
|
||||||
mempool_exit(&log->meta_pool);
|
mempool_exit(&log->meta_pool);
|
||||||
bioset_exit(&log->bs);
|
bioset_exit(&log->bs);
|
||||||
|
|||||||
Reference in New Issue
Block a user