Skip to content

Commit 7359df2

Browse files
alexeipstgNicholas Bellinger
authored andcommitted
qla2xxx: terminate exchange when command is aborted by LIO
The newly introduced aborted_task TFO callback has to terminate exchange with QLogic driver, since command is being deleted and no status will be queued to the driver at a later point. This patch also moves the burden of releasing one cmd refcount to the aborted_task handler. Changed iSCSI aborted_task logic to satisfy the above requirement. Cc: <stable@vger.kernel.org> # v3.18+ Signed-off-by: Alexei Potashnik <alexei@purestorage.com> Acked-by: Quinn Tran <quinn.tran@qlogic.com> Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent e52a8b4 commit 7359df2

File tree

3 files changed

+20
-35
lines changed

3 files changed

+20
-35
lines changed

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,20 +1924,6 @@ static int qlt_pre_xmit_response(struct qla_tgt_cmd *cmd,
19241924
struct qla_hw_data *ha = vha->hw;
19251925
struct se_cmd *se_cmd = &cmd->se_cmd;
19261926

1927-
if (unlikely(cmd->aborted)) {
1928-
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
1929-
"qla_target(%d): terminating exchange for aborted cmd=%p (se_cmd=%p, tag=%lld)",
1930-
vha->vp_idx, cmd, se_cmd, se_cmd->tag);
1931-
1932-
cmd->state = QLA_TGT_STATE_ABORTED;
1933-
cmd->cmd_flags |= BIT_6;
1934-
1935-
qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
1936-
1937-
/* !! At this point cmd could be already freed !! */
1938-
return QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED;
1939-
}
1940-
19411927
prm->cmd = cmd;
19421928
prm->tgt = tgt;
19431929
prm->rq_result = scsi_status;
@@ -2524,9 +2510,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
25242510
res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status,
25252511
&full_req_cnt);
25262512
if (unlikely(res != 0)) {
2527-
if (res == QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED)
2528-
return 0;
2529-
25302513
return res;
25312514
}
25322515

@@ -3092,6 +3075,24 @@ static void qlt_chk_exch_leak_thresh_hold(struct scsi_qla_host *vha)
30923075

30933076
}
30943077

3078+
void qlt_abort_cmd(struct qla_tgt_cmd *cmd)
3079+
{
3080+
struct qla_tgt *tgt = cmd->tgt;
3081+
struct scsi_qla_host *vha = tgt->vha;
3082+
struct se_cmd *se_cmd = &cmd->se_cmd;
3083+
3084+
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
3085+
"qla_target(%d): terminating exchange for aborted cmd=%p "
3086+
"(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd,
3087+
se_cmd->tag);
3088+
3089+
cmd->state = QLA_TGT_STATE_ABORTED;
3090+
cmd->cmd_flags |= BIT_6;
3091+
3092+
qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
3093+
}
3094+
EXPORT_SYMBOL(qlt_abort_cmd);
3095+
30953096
void qlt_free_cmd(struct qla_tgt_cmd *cmd)
30963097
{
30973098
struct qla_tgt_sess *sess = cmd->sess;

drivers/scsi/qla2xxx/qla_target.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,6 @@ int qla2x00_wait_for_hba_online(struct scsi_qla_host *);
808808
#define FC_TM_REJECT 4
809809
#define FC_TM_FAILED 5
810810

811-
/*
812-
* Error code of qlt_pre_xmit_response() meaning that cmd's exchange was
813-
* terminated, so no more actions is needed and success should be returned
814-
* to target.
815-
*/
816-
#define QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED 0x1717
817-
818811
#if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G)
819812
#define pci_dma_lo32(a) (a & 0xffffffff)
820813
#define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff)
@@ -950,7 +943,6 @@ struct qla_tgt_cmd {
950943
unsigned int conf_compl_supported:1;
951944
unsigned int sg_mapped:1;
952945
unsigned int free_sg:1;
953-
unsigned int aborted:1; /* Needed in case of SRR */
954946
unsigned int write_data_transferred:1;
955947
unsigned int ctx_dsd_alloced:1;
956948
unsigned int q_full:1;
@@ -1134,6 +1126,7 @@ static inline uint32_t sid_to_key(const uint8_t *s_id)
11341126
extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *);
11351127
extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
11361128
extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
1129+
extern void qlt_abort_cmd(struct qla_tgt_cmd *);
11371130
extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
11381131
extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
11391132
extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)
541541
cmd->cmd_flags |= BIT_4;
542542
cmd->bufflen = se_cmd->data_length;
543543
cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
544-
cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
545544

546545
cmd->sg_cnt = se_cmd->t_data_nents;
547546
cmd->sg = se_cmd->t_data_sg;
@@ -570,7 +569,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
570569
cmd->sg_cnt = 0;
571570
cmd->offset = 0;
572571
cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
573-
cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
574572
if (cmd->cmd_flags & BIT_5) {
575573
pr_crit("Bit_5 already set for cmd = %p.\n", cmd);
576574
dump_stack();
@@ -635,14 +633,7 @@ static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
635633
{
636634
struct qla_tgt_cmd *cmd = container_of(se_cmd,
637635
struct qla_tgt_cmd, se_cmd);
638-
struct scsi_qla_host *vha = cmd->vha;
639-
struct qla_hw_data *ha = vha->hw;
640-
641-
if (!cmd->sg_mapped)
642-
return;
643-
644-
pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
645-
cmd->sg_mapped = 0;
636+
qlt_abort_cmd(cmd);
646637
}
647638

648639
static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,

0 commit comments

Comments
 (0)