Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: elx: efct: report residual for status-only Data-In responses
@ 2026-12-04 18:08 Ciro Iriarte
  2026-12-04 18:31 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ciro Iriarte @ 2026-12-04 18:08 UTC (permalink / raw)
  To: Ram Vegesna, Martin K. Petersen
  Cc: James E.J. Bottomley, linux-scsi, target-devel

When a Data-In command fails before any data is sent, for example a READ
that hits a filemark or any command that returns a Unit Attention, LIO
calls ->queue_status() and the FCP_RSP carries only the status and
sense. efct_lio_queue_status() copies LIO's residual, which describes
the command's data buffer (CDB length versus FCP_DL, short backend
reads), not a data phase the fabric skipped. In the failures reproduced
here it is 0, so FCP_RESID_UNDER is not set.

The initiator HBA saw no data for a command that expected FCP_DL bytes.
qla2xxx treats an underrun without FCP_RESID_UNDER, or with a residual
that differs from what the firmware counted, as lost frames:

  qla2xxx [0000:01:00.1]-301f:12: Dropped frame(s) detected (0x100000 of 0x100000 bytes).

and completes the command with DID_ERROR instead of passing the CHECK
CONDITION up. On a tape drive this turns every read into a filemark into
a series of retries, and a Bareos restore failed when the first read
after a cartridge load returned DID_ERROR.

For DMA_FROM_DEVICE commands, report the part of FCP_DL that was not
transferred, computed as efct_scsi_send_resp() does when no response is
passed (exp_xfer_len - transferred; negative means overrun).
tcm_qla2xxx_queue_status() handles the same case by adding data_length
to the residual and setting SCF_UNDERFLOW_BIT.

Tested on an LPe31004 (efct, two ports) exporting TCMU tape devices to a
QLE2662 initiator, with 30 reads into a filemark: 120 "Dropped frame(s)"
messages before, 0 after. A Bareos backup and restore across both paths
(2.4 GB, three volumes) logged none either.

Fixes: 692e5d73a811 ("scsi: elx: efct: LIO backend interface routines")
Signed-off-by: Ciro Iriarte <ciro.iriarte+software@gmail.com>
---
 drivers/scsi/elx/efct/efct_lio.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
index 67d686dd6..033bac685 100644
--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -671,7 +671,15 @@ efct_lio_queue_status(struct se_cmd *cmd)
 	/* Check for residual underrun or overrun, mark negitive value for
 	 * underrun to recognize in HW
 	 */
-	if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT)
+	/*
+	 * For a Data-In command, report the part of FCP_DL that was not
+	 * transferred, as the initiator counts it. LIO's residual describes
+	 * the data buffer, not a data phase skipped because the command
+	 * ended with a non-GOOD status (e.g. CHECK CONDITION).
+	 */
+	if (cmd->data_direction == DMA_FROM_DEVICE)
+		rsp.residual = io->exp_xfer_len - io->transferred;
+	else if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT)
 		rsp.residual = -cmd->residual_count;
 	else if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT)
 		rsp.residual = cmd->residual_count;
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 18:08 [PATCH] scsi: elx: efct: report residual for status-only Data-In responses Ciro Iriarte
2026-12-04 18:31 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox