All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: martin.petersen@oracle.com,
	james.bottomley@hansenpartnership.com,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 1/4] scsi: target: Fix WRITE_SAME NDOB size check
Date: Thu, 16 Jun 2022 22:04:36 -0500	[thread overview]
Message-ID: <20220617030440.116427-2-michael.christie@oracle.com> (raw)
In-Reply-To: <20220617030440.116427-1-michael.christie@oracle.com>

If the WRITE_SAME NDOB bit is set then there is not going to be a
buffer. LIO core will then complain:

TARGET_CORE[iSCSI]: Expected Transfer Length: 0 does not match SCSI CDB
Length: 512 for SAM Opcode: 0x93

This fixes the issue by detecting when the bit is set and adjusting the
size.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/target_core_sbc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index ca1b2312d6e7..6d98b016a942 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -976,7 +976,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
 				return TCM_INVALID_CDB_FIELD;
 			}
 
-			size = sbc_get_size(cmd, 1);
+			/* If NDOB is set there will not be a Data-Out buffer */
+			if (cdb[1] & 0x01)
+				size = 0;
+			else
+				size = sbc_get_size(cmd, 1);
 			cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
 
 			ret = sbc_setup_write_same(cmd, cdb[10], ops);
@@ -1075,7 +1079,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
 			return TCM_INVALID_CDB_FIELD;
 		}
 
-		size = sbc_get_size(cmd, 1);
+		/* If NDOB is set there will not be a Data-Out buffer */
+		if (cdb[1] & 0x01)
+			size = 0;
+		else
+			size = sbc_get_size(cmd, 1);
 		cmd->t_task_lba = get_unaligned_be64(&cdb[2]);
 
 		ret = sbc_setup_write_same(cmd, cdb[1], ops);
-- 
2.25.1


  reply	other threads:[~2022-06-17  3:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17  3:04 [PATCH 0/4] target unmap/writespace fixes and enhancements Mike Christie
2022-06-17  3:04 ` Mike Christie [this message]
2022-06-19  6:22   ` [PATCH 1/4] scsi: target: Fix WRITE_SAME NDOB size check Christoph Hellwig
2022-06-19 16:25     ` michael.christie
2022-06-20  6:45       ` Christoph Hellwig
2022-06-20 16:03         ` Mike Christie
2022-06-17  3:04 ` [PATCH 2/4] scsi: target: Fix WRITE_SAME NDOB handling in file Mike Christie
2022-06-19  6:25   ` Christoph Hellwig
2022-06-19 16:26     ` michael.christie
2022-06-19 16:38       ` michael.christie
2022-06-17  3:04 ` [PATCH 3/4] scsi: target: Fix WRITE_SAME NDOB handling in iblock Mike Christie
2022-06-19  6:28   ` Christoph Hellwig
2022-06-17  3:04 ` [PATCH 4/4] scsi: target: Detect unmap support post configuration Mike Christie
2022-06-19  6:29   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617030440.116427-2-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.