[stgt] [PATCH] added CDB_CONTROL macro to get control field from CDB

john.chandy at uconn.edu john.chandy at uconn.edu
Tue Jun 5 13:32:43 CEST 2012


From: John A. Chandy <john.chandy at uconn.edu>

Fixes a bug in tgt/usr/scsi.c where the code expects the SCSI CONTROL
field in the last byte of the CDB.  This doesn't work for VARLEN CDBs
like OSD where the CONTROL field is the second byte of the CDB.

Signed-off-by: John Chandy <john.chandy at uconn.edu>
---
 usr/scsi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/usr/scsi.c b/usr/scsi.c
index 4ec81d1..3d46ac1 100644
--- a/usr/scsi.c
+++ b/usr/scsi.c
@@ -43,6 +43,8 @@ static unsigned char scsi_command_size[8] = {6, 10, 10, 12, 16, 12, 10, 10};
 #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
 #define CDB_SIZE(cmd) (((((cmd)->scb[0] >> 5) & 7) < 6) ? \
 				COMMAND_SIZE((cmd)->scb[0]) : (cmd)->scb_len)
+#define CDB_CONTROL(cmd) (((cmd)->scb[0] == 0x7f) ? (cmd)->scb[1] \
+			  : (cmd)->scb[CDB_SIZE((cmd))-1])
 
 int get_scsi_command_size(unsigned char op)
 {
@@ -189,7 +191,7 @@ int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd)
 	unsigned char op = cmd->scb[0];
 	struct it_nexus_lu_info *itn_lu;
 
-	if (cmd->scb[CDB_SIZE(cmd) - 1] & ((1U << 0) | (1U << 2))) {
+	if (CDB_CONTROL(cmd) & ((1U << 0) | (1U << 2))) {
 		/*
 		 * We don't support a linked command. SAM-3 say that
 		 * it's optional. It's obsolete in SAM-4.
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list