Skip to contentSkip to conversation

qla2xxx: Fix a possible hang on target shutdown

PATCH Applied Roland Dreier 2 participants 2 messages Jan 12, 2012 – Jan 13, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qla2xxx: Fix a possible hang on target shutdown

From: Roland Dreier <[email protected]>

If tgt->tgt_stop is set, current code in qla_tgt_do_work() jumps to the exit path before setting sess, so the code

        if (sess)
                __qla_tgt_sess_put(sess);

skips the kref_put() and therefore sess is be left with an extra reference forever. When this happens, qla_tgt_stop_phase1() waits forever for all the sessions to go away. Fix this by making sure sess is always set in qla_tgt_do_work().

---
 drivers/scsi/qla2xxx/qla_target.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +1 -2
index b1ef4b1..51de953 100644
@@ -2955,7 +2955,7 @@ static void qla_tgt_do_work(struct work_struct *work)
 	scsi_qla_host_t *vha = cmd->vha;
 	struct qla_hw_data *ha = vha->hw;
 	struct qla_tgt *tgt = ha->qla_tgt;
-	struct qla_tgt_sess *sess = NULL;
+	struct qla_tgt_sess *sess = cmd->sess;
 	atio_from_isp_t *atio = &cmd->atio;
 	unsigned char *cdb;
 	unsigned long flags;
@@ -2965,7 +2965,6 @@ static void qla_tgt_do_work(struct work_struct *work)
 	if (tgt->tgt_stop)
 		goto out_term;	
 
-	sess = cmd->sess;
 	if (!sess) {
 		uint8_t *s_id = NULL;
 		uint16_t loop_id = 0;
Signature · 1 line
1.7.8.3
#1 lore raw
Quoted 32 lines · Roland Dreier

From: Roland Dreier <[email protected]>

If tgt->tgt_stop is set, current code in qla_tgt_do_work() jumps to the exit path before setting sess, so the code

        if (sess)
                __qla_tgt_sess_put(sess);

skips the kref_put() and therefore sess is be left with an extra reference forever. When this happens, qla_tgt_stop_phase1() waits forever for all the sessions to go away. Fix this by making sure sess is always set in qla_tgt_do_work().

---
 drivers/scsi/qla2xxx/qla_target.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +1 -1
index b1ef4b1..51de953 100644
@@ -2955,7 +2955,7 @@ static void qla_tgt_do_work(struct work_struct *work)
 	scsi_qla_host_t *vha = cmd->vha;
 	struct qla_hw_data *ha = vha->hw;
 	struct qla_tgt *tgt = ha->qla_tgt;
-	struct qla_tgt_sess *sess = NULL;
+	struct qla_tgt_sess *sess = cmd->sess;
 	atio_from_isp_t *atio = &cmd->atio;
 	unsigned char *cdb;
 	unsigned long flags;

drivers/scsi/qla2xxx/qla_target.c static void qla_tgt_do_work(struct work_struct *work) · line 2970

Quoted 7 lines
drivers/scsi/qla2xxx/qla_target.c +0 -1
@@ -2965,7 +2965,6 @@ static void qla_tgt_do_work(struct work_struct *work)
 	if (tgt->tgt_stop)
 		goto out_term;	
 
-	sess = cmd->sess;
 	if (!sess) {
 		uint8_t *s_id = NULL;
 		uint16_t loop_id = 0;

A very nice catch here Roland.

Applied to lio-core/qla_tgt-3.3, and will make sure this is included in the next RFC.

Thanks,

--nab