[Stgt-devel] [PATCH 2/4] track target type

Pete Wyckoff pw
Mon Jan 22 20:03:34 CET 2007


Track target type (block, mmc, osd, etc.) and pass it to
scsi_cmd_perform.

Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
 usr/scsi.c   |    2 +-
 usr/target.c |    7 +++++--
 usr/target.h |    1 +
 usr/tgtd.h   |   10 +++++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/usr/scsi.c b/usr/scsi.c
index e65e893..82ddb0d 100644
--- a/usr/scsi.c
+++ b/usr/scsi.c
@@ -482,7 +482,7 @@ int scsi_cmd_perform(uint64_t nid, int lid, int host_no, uint8_t *pdu,
 		     int *len, uint32_t datalen, unsigned long *uaddr, uint8_t *rw,
 		     uint8_t *try_map, uint64_t *offset, uint8_t *lun_buf,
 		     struct tgt_device *dev, struct list_head *dev_list, int *async,
-		     void *key, bkio_submit_t *submit)
+		     void *key, bkio_submit_t *submit, enum scsi_target_type target_type)
 {
 	int result = SAM_STAT_GOOD;
 	uint8_t *data = NULL, *scb = pdu;
diff --git a/usr/target.c b/usr/target.c
index 93e7531..3d0f790 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -462,7 +462,8 @@ int target_cmd_queue(uint64_t nid, uint8_t *scb, uint8_t rw,
 					  &uaddr, &rw, &mmapped, &offset,
 					  lun, cmd->dev,
 					  &target->device_list, &async, (void *) cmd,
-					  target->bdt->bd_cmd_submit);
+					  target->bdt->bd_cmd_submit,
+					  target->target_type);
 
 		cmd_post_perform(q, cmd, uaddr, len, mmapped);
 
@@ -530,7 +531,8 @@ static void post_cmd_done(struct tgt_cmd_queue *q)
 						  cmd->lun, cmd->dev,
 						  &cmd->c_target->device_list,
 						  &async, (void *) cmd,
-						  cmd->c_target->bdt->bd_cmd_submit);
+						  cmd->c_target->bdt->bd_cmd_submit,
+						  cmd->c_target->target_type);
 			cmd->rw = rw;
 			cmd_post_perform(q, cmd, cmd->uaddr, len, mmapped);
 			set_cmd_processed(cmd);
@@ -1275,6 +1277,7 @@ int tgt_target_create(int lld, int tid, char *args, int t_type, int bs_type)
 		target->bdt = tgt_drivers[lld]->default_bdt;
 	}
 
+	target->target_type = t_type;
 	target->target_state = SCSI_TARGET_RUNNING;
 	target->lid = lld;
 
diff --git a/usr/target.h b/usr/target.h
index 0cca55f..e19ca73 100644
--- a/usr/target.h
+++ b/usr/target.h
@@ -39,6 +39,7 @@ struct target {
 	int lid;
 
 	enum scsi_target_iotype target_iotype;
+	enum scsi_target_type target_type;
 	enum scsi_target_state target_state;
 
 	struct list_head target_siblings;
diff --git a/usr/tgtd.h b/usr/tgtd.h
index ef046aa..090f84a 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -21,6 +21,13 @@ enum scsi_target_iotype {
 	SCSI_TARGET_RAWIO,
 };
 
+enum scsi_target_type {
+	SCSI_TARGET_SBC, /* disk */
+	SCSI_TARGET_SSC, /* tape */
+	SCSI_TARGET_MMC, /* cdrom */
+	SCSI_TARGET_OSD, /* object storage device */
+};
+
 enum scsi_target_state {
 	SCSI_TARGET_SUSPENDED = 1,
 	SCSI_TARGET_RUNNING,
@@ -111,7 +118,8 @@ extern int scsi_cmd_perform(uint64_t nid, int lid, int host_no, uint8_t *pdu, in
 			    uint32_t datalen, unsigned long *uaddr, uint8_t *rw,
 			    uint8_t *try_map, uint64_t *offset, uint8_t *lun,
 			    struct tgt_device *dev, struct list_head *dev_list,
-			    int *async, void *key, bkio_submit_t *submit);
+			    int *async, void *key, bkio_submit_t *submit,
+			    enum scsi_target_type target_type);
 
 extern int sense_data_build(uint8_t *data, uint8_t res_code, uint8_t key,
 			    uint8_t ascode, uint8_t ascodeq);
-- 
1.4.4.2




More information about the stgt mailing list