Skip to content

Commit f200dad

Browse files
Merge patch series "libfc: fixup command abort handling"
Hannes Reinecke <hare@kernel.org> says: Hi all, when testing command timeout with the help of XDP I found that scsi_try_to_abort_cmd() would always return 'SUCCESS' for FCoE, even if no commands could be sent over the wire. Which is not only surprising, but also can lead to data corruption as commands were never aborted. Root cause was that aborts had been sent twice, once from FC error recovery and once from SCSI EH, with the former inducing the latter to assume that the command was already aborted. As usual, comments and reviews are welcome. Link: https://lore.kernel.org/r/20231129165832.224100-1-hare@kernel.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 parents aef6ac1 + be40572 commit f200dad

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

drivers/scsi/libfc/fc_fcp.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp)
265265
if (!fsp->seq_ptr)
266266
return -EINVAL;
267267

268+
if (fsp->state & FC_SRB_ABORT_PENDING) {
269+
FC_FCP_DBG(fsp, "abort already pending\n");
270+
return -EBUSY;
271+
}
272+
268273
this_cpu_inc(fsp->lp->stats->FcpPktAborts);
269274

270275
fsp->state |= FC_SRB_ABORT_PENDING;
@@ -1671,7 +1676,7 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
16711676
if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY)
16721677
fc_fcp_rec(fsp);
16731678
else
1674-
fc_fcp_recovery(fsp, FC_ERROR);
1679+
fc_fcp_recovery(fsp, FC_TIMED_OUT);
16751680
break;
16761681
}
16771682
fc_fcp_unlock_pkt(fsp);
@@ -1690,11 +1695,12 @@ static void fc_fcp_recovery(struct fc_fcp_pkt *fsp, u8 code)
16901695
fsp->status_code = code;
16911696
fsp->cdb_status = 0;
16921697
fsp->io_status = 0;
1693-
/*
1694-
* if this fails then we let the scsi command timer fire and
1695-
* scsi-ml escalate.
1696-
*/
1697-
fc_fcp_send_abort(fsp);
1698+
if (!fsp->cmd)
1699+
/*
1700+
* Only abort non-scsi commands; otherwise let the
1701+
* scsi command timer fire and scsi-ml escalate.
1702+
*/
1703+
fc_fcp_send_abort(fsp);
16981704
}
16991705

17001706
/**
@@ -2056,9 +2062,9 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
20562062
sc_cmd->result = (DID_PARITY << 16);
20572063
break;
20582064
case FC_TIMED_OUT:
2059-
FC_FCP_DBG(fsp, "Returning DID_BUS_BUSY to scsi-ml "
2065+
FC_FCP_DBG(fsp, "Returning DID_TIME_OUT to scsi-ml "
20602066
"due to FC_TIMED_OUT\n");
2061-
sc_cmd->result = (DID_BUS_BUSY << 16) | fsp->io_status;
2067+
sc_cmd->result = (DID_TIME_OUT << 16);
20622068
break;
20632069
default:
20642070
FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "

0 commit comments

Comments
 (0)