[Stgt-devel] [PATCH] pass cdb length

Pete Wyckoff pw
Sun Feb 25 01:22:43 CET 2007


Large CDBs are needed for OSD commands.  Pass the length of the command
as well as the CDB itself.

Signed-off-by: Pete Wyckoff <pw at osc.edu>
---

 usr/iscsi/iscsid.c |    4 ++--
 usr/target.c       |    6 ++++--
 usr/target.h       |    3 ++-
 usr/tgtd.h         |    2 +-
 usr/tgtif.c        |    2 +-
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 8ea1092..6726c7d 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -953,14 +953,14 @@ static int iscsi_scsi_cmd_execute(struct iscsi_task *task)
 				list_add_tail(&task->c_list, &task->conn->tx_clist);
 		} else
 			err = target_cmd_queue(conn->session->iscsi_nexus_id,
-					       req->cdb,
+					       req->cdb, 16,
 					       req->flags & ISCSI_FLAG_CMD_WRITE,
 					       uaddr, req->lun,
 					       ntohl(req->data_length),
 					       cmd_attr(task), req->itt);
 	} else
 		err = target_cmd_queue(conn->session->iscsi_nexus_id,
-				       req->cdb,
+				       req->cdb, 16,
 				       req->flags & ISCSI_FLAG_CMD_WRITE,
 				       uaddr, req->lun, ntohl(req->data_length),
 				       cmd_attr(task), req->itt);
diff --git a/usr/target.c b/usr/target.c
index c101b39..6cb69ce 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -388,7 +388,7 @@ static void cmd_post_perform(struct tgt_cmd_queue *q, struct scsi_cmd *cmd)
 	}
 }
 
-int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
+int target_cmd_queue(uint64_t nid, uint8_t *scb, int scblen, uint8_t rw,
 		     unsigned long uaddr,
 		     uint8_t *lun, uint32_t data_len,
 		     int attribute, uint64_t tag)
@@ -409,7 +409,7 @@ int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
 
 	target = nexus->nexus_target;
 	/* TODO: preallocate cmd */
-	cmd = zalloc(sizeof(*cmd));
+	cmd = zalloc(sizeof(*cmd) + scblen);
 	if (!cmd)
 		return -ENOMEM;
 
@@ -419,6 +419,8 @@ int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
 	cmd->tag = tag;
 	cmd->uaddr = uaddr;
 	cmd->len = data_len;
+	cmd->scb = (void *) (cmd + 1);
+	cmd->scblen = scblen;
 	memcpy(cmd->scb, scb, sizeof(cmd->scb));
 	memcpy(cmd->lun, lun, sizeof(cmd->lun));
 
diff --git a/usr/target.h b/usr/target.h
index aecee7c..e90b094 100644
--- a/usr/target.h
+++ b/usr/target.h
@@ -90,7 +90,8 @@ struct scsi_cmd {
 	uint64_t cmd_nexus_id;
 	uint32_t data_len;
 	uint64_t offset;
-	uint8_t scb[16];
+	uint8_t *scb;
+	int scblen;
 	uint8_t lun[8];
 	int attribute;
 	uint64_t tag;
diff --git a/usr/tgtd.h b/usr/tgtd.h
index eb9dd2e..b4d8146 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -103,7 +103,7 @@ extern int tgt_event_add(int fd, int events, event_handler_t handler, void *data
 extern void tgt_event_del(int fd);
 extern int tgt_event_modify(int fd, int events);
 
-extern int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
+extern int target_cmd_queue(uint64_t nid, uint8_t *scb, int scblen, uint8_t rw,
 			    unsigned long uaddr,
 			    uint8_t *lun, uint32_t data_len,
 			    int attribute, uint64_t tag);
diff --git a/usr/tgtif.c b/usr/tgtif.c
index 76545f6..4c22863 100644
--- a/usr/tgtif.c
+++ b/usr/tgtif.c
@@ -132,7 +132,7 @@ retry:
 	switch (ev->hdr.type) {
 	case TGT_KEVENT_CMD_REQ:
 		target_cmd_queue(host_no_to_it_nexus(ev->p.cmd_req.host_no),
-				 ev->p.cmd_req.scb,
+				 ev->p.cmd_req.scb, 16,
 				 0, 0,
 /* 				 ev->k.cmd_req.uaddr, */
 				 ev->p.cmd_req.lun, ev->p.cmd_req.data_len,



More information about the stgt mailing list