* [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* Re: [PATCH] scsi: elx: efct: report residual for status-only Data-In responses
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
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 18:31 UTC (permalink / raw)
To: Ciro Iriarte; +Cc: linux-scsi, target-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: elx: efct: signed int wrap of rsp.residual in
efct_lio_queue_status()
- [Low] scsi: elx: efct: contradictory stale comment left in
efct_lio_queue_status()
--
commit a54c529a9f1575d63dad16f1055e12ab0ca4bab4
Author: Ciro Iriarte <ciro.iriarte+software@gmail.com>
scsi: elx: efct: report residual for status-only Data-In responses
This patch changes efct_lio_queue_status() to compute rsp.residual as
io->exp_xfer_len - io->transferred for DMA_FROM_DEVICE commands instead
of copying LIO's residual_count.
> diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
> index 67d686dd6fb33..033bac6856549 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).
> + */
[Severity: Low]
This isn't a bug, but the old comment right above the new one has the
sign backwards ("mark negitive value for underrun", while negative
means overrun here and in efct_scsi_send_resp()). Replacing the old
comment instead of stacking both would avoid the contradiction.
> + if (cmd->data_direction == DMA_FROM_DEVICE)
> + rsp.residual = io->exp_xfer_len - io->transferred;
[Severity: Medium]
Can rsp.residual wrap to a negative value when a Data-In command has
FCP_DL >= 0x80000000 and fails before transferring data?
efct_populate_io_fcp_cmd() sets u32 io->exp_xfer_len directly from
be32_to_cpu(cmnd->fc_dl) without bounding it to INT_MAX, while
rsp.residual in struct efct_scsi_cmd_resp is a signed 32-bit int.
With io->transferred == 0, values >= 0x80000000 wrap into [INT_MIN, -1].
efct_scsi_send_resp() then treats residual <= 0 as an overrun, setting
FCP_RESID_OVER instead of FCP_RESID_UNDER and negating residual, which
corrupts the wire count and overflows signed int at INT_MIN.
Widening residual to s64 (or using a u32 residual with an explicit
direction flag) would cover the full 32-bit FCP_DL range.
--
Sashiko AI review · https://sashiko.dev/#/patchset/b82e2805-2368-43c6-9686-927fcf8731d6@gmail.com?part=1
^ permalink raw reply [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