Skip to content

Commit 3e5844b

Browse files
committed
qla2xxx: fix session free stall by using scst_unregister_session wait=0
Calling scst_unregister_session(wait=1) from qlt_free_session_done blocks the qla2xxx_wq worker until session teardown completes, but teardown requires the TM thread to process SCST_UNREG_SESS_TM while the TM thread is blocked on scst_mutex held by concurrent session teardown in the global management thread. Under load this stall exceeds the hung-task timeout. Switch to wait=0 and wait on fcport->unreg_done instead, matching the pattern in iscsi-scst.
1 parent 7ba3768 commit 3e5844b

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,23 @@ static void sqa_qla2xxx_free_session(struct fc_port *fcport)
740740
DECLARE_COMPLETION_ONSTACK(c);
741741

742742
fcport->unreg_done = &c;
743-
scst_unregister_session(scst_sess, 1, sqa_free_session_done);
743+
/*
744+
* Use wait=0 (async) to avoid a severe stall under concurrent
745+
* session teardown. With wait=1 the workqueue thread blocks
746+
* inside scst_unregister_session() until
747+
* scst_free_session_callback() fires. That callback cannot be
748+
* scheduled until the TM thread processes SCST_UNREG_SESS_TM,
749+
* but the TM thread is blocked on scst_mutex which the global
750+
* management thread holds during concurrent session teardown
751+
* (scst_sess_free_tgt_devs -> synchronize_rcu()). Under load
752+
* this stall exceeds the hung-task timeout. With wait=0 the
753+
* workqueue thread is released immediately; we wait only on
754+
* fcport->unreg_done, signalled by sqa_free_session_done() at
755+
* a point where scst_mutex is not held.
756+
* See also: iscsi-scst session_free() which carries a similar
757+
* warning.
758+
*/
759+
scst_unregister_session(scst_sess, 0, sqa_free_session_done);
744760
wait_for_completion(&c);
745761
}
746762

0 commit comments

Comments
 (0)