* [PATCH] tcm_qla2xxx: Fix residual for underrun commands that fail
@ 2013-06-05 16:54 Roland Dreier
2013-06-14 21:10 ` Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Roland Dreier @ 2013-06-05 16:54 UTC (permalink / raw)
To: Nicholas A. Bellinger
Cc: target-devel, linux-scsi, linux-driver, Roland Dreier
From: Roland Dreier <roland@purestorage.com>
Suppose an initiator sends a DATA IN command with an allocation length
shorter than the FC transfer length -- we get a target message like
TARGET_CORE[qla2xxx]: Expected Transfer Length: 256 does not match SCSI CDB Length: 0 for SAM Opcode: 0x12
In that case, the target core adjusts the data_length and sets
se_cmd->residual_count for the underrun. But now suppose that command
fails and we end up in tcm_qla2xxx_queue_status() -- that function
unconditionally overwrites residual_count with the already adjusted
data_length, and the initiator will burp with a message like
qla2xxx [0000:00:06.0]-301d:0: Dropped frame(s) detected (0x100 of 0x100 bytes).
Fix this by adding on to the existing underflow residual count instead.
Signed-off-by: Roland Dreier <roland@purestorage.com>
---
drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 7a3870f..66b0b26 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -688,8 +688,12 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
* For FCP_READ with CHECK_CONDITION status, clear cmd->bufflen
* for qla_tgt_xmit_response LLD code
*/
+ if (se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
+ se_cmd->se_cmd_flags &= ~SCF_OVERFLOW_BIT;
+ se_cmd->residual_count = 0;
+ }
se_cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT;
- se_cmd->residual_count = se_cmd->data_length;
+ se_cmd->residual_count += se_cmd->data_length;
cmd->bufflen = 0;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tcm_qla2xxx: Fix residual for underrun commands that fail
2013-06-05 16:54 [PATCH] tcm_qla2xxx: Fix residual for underrun commands that fail Roland Dreier
@ 2013-06-14 21:10 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2013-06-14 21:10 UTC (permalink / raw)
To: Roland Dreier
Cc: target-devel, linux-scsi, linux-driver, Roland Dreier,
Giridhar Malavali, Chad Dupuis
Hi Roland,
On Wed, 2013-06-05 at 09:54 -0700, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
>
> Suppose an initiator sends a DATA IN command with an allocation length
> shorter than the FC transfer length -- we get a target message like
>
> TARGET_CORE[qla2xxx]: Expected Transfer Length: 256 does not match SCSI CDB Length: 0 for SAM Opcode: 0x12
>
> In that case, the target core adjusts the data_length and sets
> se_cmd->residual_count for the underrun. But now suppose that command
> fails and we end up in tcm_qla2xxx_queue_status() -- that function
> unconditionally overwrites residual_count with the already adjusted
> data_length, and the initiator will burp with a message like
>
> qla2xxx [0000:00:06.0]-301d:0: Dropped frame(s) detected (0x100 of 0x100 bytes).
>
> Fix this by adding on to the existing underflow residual count instead.
>
> Signed-off-by: Roland Dreier <roland@purestorage.com>
> ---
Apologies for the delay, finally catching up on the backlog..
Applied to target-pending/master, with a CC' to stable.
Also including QLogic folks on the CC'.
Thanks!
--nab
> drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 7a3870f..66b0b26 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -688,8 +688,12 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
> * For FCP_READ with CHECK_CONDITION status, clear cmd->bufflen
> * for qla_tgt_xmit_response LLD code
> */
> + if (se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
> + se_cmd->se_cmd_flags &= ~SCF_OVERFLOW_BIT;
> + se_cmd->residual_count = 0;
> + }
> se_cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT;
> - se_cmd->residual_count = se_cmd->data_length;
> + se_cmd->residual_count += se_cmd->data_length;
>
> cmd->bufflen = 0;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-14 21:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 16:54 [PATCH] tcm_qla2xxx: Fix residual for underrun commands that fail Roland Dreier
2013-06-14 21:10 ` Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).