mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-21 20:51:27 +00:00
Prevent potential deadlock between scst_del_threads() and commands taking scst_mutex
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5532 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -6060,10 +6060,20 @@ static int scst_process_threads_store(int newtn)
|
||||
|
||||
TRACE_DBG("newtn %d", newtn);
|
||||
|
||||
res = mutex_lock_interruptible(&scst_mutex);
|
||||
/*
|
||||
* Some commands are taking scst_mutex on commands processing path,
|
||||
* so we need to drain them, because otherwise we can fall into a
|
||||
* deadlock with kthread_stop() in scst_del_threads() waiting for
|
||||
* those commands to finish.
|
||||
*/
|
||||
res = scst_suspend_activity(SCST_SUSPEND_TIMEOUT_USER);
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = mutex_lock_interruptible(&scst_mutex);
|
||||
if (res != 0)
|
||||
goto out_resume;
|
||||
|
||||
oldtn = scst_main_cmd_threads.nr_threads;
|
||||
|
||||
delta = newtn - oldtn;
|
||||
@@ -6080,6 +6090,9 @@ static int scst_process_threads_store(int newtn)
|
||||
out_up:
|
||||
mutex_unlock(&scst_mutex);
|
||||
|
||||
out_resume:
|
||||
scst_resume_activity();
|
||||
|
||||
out:
|
||||
TRACE_EXIT_RES(res);
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user