[Stgt-devel] [PATCH] pass scb length

Pete Wyckoff pw
Mon Mar 5 21:36:25 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       |    8 +++++---
 usr/tgtd.h         |    5 +++--
 usr/tgtif.c        |    2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 68c3c77..3178df6 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -987,14 +987,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 4be4aa2..8fa12cc 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -391,7 +391,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)
@@ -412,7 +412,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;
 
@@ -423,7 +423,9 @@ int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
 	cmd->uaddr = uaddr;
 	cmd->len = data_len;
 	cmd->rw = rw;
-	memcpy(cmd->scb, scb, sizeof(cmd->scb));
+ 	cmd->scb = (void *) (cmd + 1);
+ 	cmd->scblen = scblen;
+ 	memcpy(cmd->scb, scb, scblen);
 	memcpy(cmd->lun, lun, sizeof(cmd->lun));
 
 	cmd_hlist_insert(target, cmd);
diff --git a/usr/tgtd.h b/usr/tgtd.h
index d2a79c1..a6cc287 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -73,7 +73,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;
@@ -126,7 +127,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 3d54aa1..0328c1d 100644
--- a/usr/tgtif.c
+++ b/usr/tgtif.c
@@ -136,7 +136,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,
-- 
1.5.0.2




More information about the stgt mailing list