Skip to content

Commit 04957d8

Browse files
abattersbymartinkpetersen
authored andcommitted
scsi: qla2xxx: target: Improve cmd logging
- Add the command tag to various messages so that different messages about the same command can be correlated. - For CTIO errors (i.e. when the HW reports an error about a cmd), print the cmd tag, opcode, state, initiator WWPN, and LUN. This info helps an administrator determine what is going wrong. - When a command experiences a transport error, log a message when it is freed. This makes debugging exceptions easier. Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Link: https://patch.msgid.link/c579987d-5658-41ae-9653-f0e58c9d1880@cybernetics.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f4199d5 commit 04957d8

2 files changed

Lines changed: 64 additions & 26 deletions

File tree

drivers/scsi/qla2xxx/qla_dbg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* | Misc | 0xd303 | 0xd031-0xd0ff |
5555
* | | | 0xd101-0xd1fe |
5656
* | | | 0xd214-0xd2fe |
57-
* | Target Mode | 0xe084 | |
57+
* | Target Mode | 0xe086 | |
5858
* | Target Mode Management | 0xf09b | 0xf002 |
5959
* | | | 0xf046-0xf049 |
6060
* | Target Mode Task Management | 0x1000d | |

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,8 +1984,12 @@ static void abort_cmds_for_lun(struct scsi_qla_host *vha, u64 lun, be_id_t s_id)
19841984
cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
19851985
cmd_lun = scsilun_to_int(
19861986
(struct scsi_lun *)&cmd->atio.u.isp24.fcp_cmnd.lun);
1987-
if (cmd_key == key && cmd_lun == lun)
1987+
if (cmd_key == key && cmd_lun == lun) {
1988+
ql_dbg(ql_dbg_tgt_mgt, vha, 0xe085,
1989+
"qla_target(%d): tag %lld: aborted by TMR\n",
1990+
vha->vp_idx, cmd->se_cmd.tag);
19881991
cmd->aborted = 1;
1992+
}
19891993
}
19901994
spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
19911995
}
@@ -3841,6 +3845,15 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
38413845

38423846
BUG_ON(cmd->sg_mapped);
38433847

3848+
if (unlikely(cmd->aborted ||
3849+
(cmd->trc_flags & (TRC_CTIO_STRANGE | TRC_CTIO_ERR)))) {
3850+
ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xe086,
3851+
"qla_target(%d): tag %lld: free cmd (trc_flags %x, aborted %u, sent_term_exchg %u, rsp_sent %u)\n",
3852+
cmd->vha->vp_idx, cmd->se_cmd.tag,
3853+
cmd->trc_flags, cmd->aborted, cmd->sent_term_exchg,
3854+
cmd->rsp_sent);
3855+
}
3856+
38443857
if (unlikely(cmd->cdb != &cmd->atio.u.isp24.fcp_cmnd.cdb[0])) {
38453858
kfree(cmd->cdb);
38463859
cmd->cdb = &cmd->atio.u.isp24.fcp_cmnd.cdb[0];
@@ -3853,7 +3866,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
38533866
WARN_ON(1);
38543867
return;
38553868
}
3856-
cmd->jiffies_at_free = get_jiffies_64();
38573869
cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd);
38583870
}
38593871
EXPORT_SYMBOL(qlt_free_cmd);
@@ -3918,7 +3930,6 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
39183930
struct ctio7_from_24xx *ctio)
39193931
{
39203932
struct qla_hw_data *ha = vha->hw;
3921-
struct se_cmd *se_cmd;
39223933
struct qla_tgt_cmd *cmd;
39233934
struct qla_qpair *qpair = rsp->qpair;
39243935
uint16_t ctio_flags;
@@ -3957,12 +3968,12 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
39573968
if ((ctio_flags & CTIO7_FLAGS_DATA_OUT) && cmd->sess)
39583969
qlt_chk_edif_rx_sa_delete_pending(vha, cmd->sess, ctio);
39593970

3960-
se_cmd = &cmd->se_cmd;
39613971
cmd->cmd_sent_to_fw = 0;
39623972

39633973
qlt_unmap_sg(vha, cmd);
39643974

39653975
if (unlikely(status != CTIO_SUCCESS)) {
3976+
u8 op = cmd->cdb ? cmd->cdb[0] : 0;
39663977
bool term_exchg = false;
39673978

39683979
/*
@@ -3980,8 +3991,10 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
39803991
term_exchg = true;
39813992
if (printk_ratelimit())
39823993
dev_info(&vha->hw->pdev->dev,
3983-
"qla_target(%d): CTIO with INVALID_RX_ID ATIO attr %x CTIO Flags %x|%x\n",
3984-
vha->vp_idx, cmd->atio.u.isp24.attr,
3994+
"qla_target(%d): tag %lld, op %x: CTIO with INVALID_RX_ID status 0x%x received (state %d, port %8phC, LUN %lld, ATIO attr %x, CTIO Flags %x|%x)\n",
3995+
vha->vp_idx, cmd->se_cmd.tag, op,
3996+
status, cmd->state, cmd->sess->port_name,
3997+
cmd->unpacked_lun, cmd->atio.u.isp24.attr,
39853998
((cmd->ctio_flags >> 9) & 0xf),
39863999
cmd->ctio_flags);
39874000
break;
@@ -3992,13 +4005,31 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
39924005
term_exchg = true;
39934006
fallthrough;
39944007
case CTIO_TIMEOUT:
4008+
{
4009+
const char *status_str;
4010+
4011+
switch (status & 0xFFFF) {
4012+
case CTIO_LIP_RESET:
4013+
status_str = "LIP_RESET";
4014+
break;
4015+
case CTIO_TARGET_RESET:
4016+
status_str = "TARGET_RESET";
4017+
break;
4018+
case CTIO_ABORTED:
4019+
status_str = "ABORTED";
4020+
break;
4021+
case CTIO_TIMEOUT:
4022+
default:
4023+
status_str = "TIMEOUT";
4024+
break;
4025+
}
39954026
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf058,
3996-
"qla_target(%d): CTIO with "
3997-
"status %#x received, state %x, se_cmd %p, "
3998-
"(LIP_RESET=e, ABORTED=2, TARGET_RESET=17, "
3999-
"TIMEOUT=b, INVALID_RX_ID=8)\n", vha->vp_idx,
4000-
status, cmd->state, se_cmd);
4027+
"qla_target(%d): tag %lld, op %x: CTIO with %s status 0x%x received (state %d, port %8phC, LUN %lld)\n",
4028+
vha->vp_idx, cmd->se_cmd.tag, op,
4029+
status_str, status, cmd->state,
4030+
cmd->sess->port_name, cmd->unpacked_lun);
40014031
break;
4032+
}
40024033

40034034
case CTIO_PORT_LOGGED_OUT:
40044035
case CTIO_PORT_UNAVAILABLE:
@@ -4007,10 +4038,11 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
40074038
(status & 0xFFFF) == CTIO_PORT_LOGGED_OUT;
40084039

40094040
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
4010-
"qla_target(%d): CTIO with %s status %x "
4011-
"received (state %x, se_cmd %p)\n", vha->vp_idx,
4041+
"qla_target(%d): tag %lld, op %x: CTIO with %s status 0x%x received (state %d, port %8phC, LUN %lld)\n",
4042+
vha->vp_idx, cmd->se_cmd.tag, op,
40124043
logged_out ? "PORT LOGGED OUT" : "PORT UNAVAILABLE",
4013-
status, cmd->state, se_cmd);
4044+
status, cmd->state, cmd->sess->port_name,
4045+
cmd->unpacked_lun);
40144046

40154047
term_exchg = true;
40164048
if (logged_out && cmd->sess) {
@@ -4027,14 +4059,15 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
40274059
}
40284060
break;
40294061
}
4062+
40304063
case CTIO_DIF_ERROR: {
40314064
struct ctio_crc_from_fw *crc =
40324065
(struct ctio_crc_from_fw *)ctio;
40334066
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf073,
4034-
"qla_target(%d): CTIO with DIF_ERROR status %x "
4035-
"received (state %x, ulp_cmd %p) actual_dif[0x%llx] "
4036-
"expect_dif[0x%llx]\n",
4037-
vha->vp_idx, status, cmd->state, se_cmd,
4067+
"qla_target(%d): tag %lld, op %x: CTIO with DIF_ERROR status 0x%x received (state %d, port %8phC, LUN %lld, actual_dif[0x%llx] expect_dif[0x%llx])\n",
4068+
vha->vp_idx, cmd->se_cmd.tag, op, status,
4069+
cmd->state, cmd->sess->port_name,
4070+
cmd->unpacked_lun,
40384071
*((u64 *)&crc->actual_dif[0]),
40394072
*((u64 *)&crc->expected_dif[0]));
40404073

@@ -4047,14 +4080,18 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
40474080
case CTIO_FAST_INVALID_REQ:
40484081
case CTIO_FAST_SPI_ERR:
40494082
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05b,
4050-
"qla_target(%d): CTIO with EDIF error status 0x%x received (state %x, se_cmd %p\n",
4051-
vha->vp_idx, status, cmd->state, se_cmd);
4083+
"qla_target(%d): tag %lld, op %x: CTIO with EDIF error status 0x%x received (state %d, port %8phC, LUN %lld)\n",
4084+
vha->vp_idx, cmd->se_cmd.tag, op, status,
4085+
cmd->state, cmd->sess->port_name,
4086+
cmd->unpacked_lun);
40524087
break;
40534088

40544089
default:
40554090
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05b,
4056-
"qla_target(%d): CTIO with error status 0x%x received (state %x, se_cmd %p\n",
4057-
vha->vp_idx, status, cmd->state, se_cmd);
4091+
"qla_target(%d): tag %lld, op %x: CTIO with error status 0x%x received (state %d, port %8phC, LUN %lld)\n",
4092+
vha->vp_idx, cmd->se_cmd.tag, op, status,
4093+
cmd->state, cmd->sess->port_name,
4094+
cmd->unpacked_lun);
40584095
break;
40594096
}
40604097

@@ -4092,12 +4129,13 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
40924129
} else if (cmd->aborted) {
40934130
cmd->trc_flags |= TRC_CTIO_ABORTED;
40944131
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e,
4095-
"Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag);
4132+
"qla_target(%d): tag %lld: Aborted command finished\n",
4133+
vha->vp_idx, cmd->se_cmd.tag);
40964134
} else {
40974135
cmd->trc_flags |= TRC_CTIO_STRANGE;
40984136
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c,
4099-
"qla_target(%d): A command in state (%d) should "
4100-
"not return a CTIO complete\n", vha->vp_idx, cmd->state);
4137+
"qla_target(%d): tag %lld: A command in state (%d) should not return a CTIO complete\n",
4138+
vha->vp_idx, cmd->se_cmd.tag, cmd->state);
41014139
}
41024140

41034141
if (unlikely(status != CTIO_SUCCESS) &&

0 commit comments

Comments
 (0)