Skip to contentSkip to conversation

: Add bs_sg_init() for STGT LUN passthrough

PATCH In review Nicholas A. Bellinger 1 participant 1 message Jun 1, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 : Add bs_sg_init() for STGT LUN passthrough

From: Nicholas Bellinger <[email protected]>

This patch adds bs_sg_init() that is called from existing usr/target.c:tgt_device_create() code via struct backingstore_template->bs_init() in order to setup the passthrough specific queue and completion handlers for struct scsi_lu->cmd_perform() and ->cmd_done().

---
 usr/bs_sg.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
usr/bs_sg.c +20 -0
index 8baa480..2fcb0d2 100644
@@ -192,6 +192,25 @@ static int init_sg_device(int fd)
 	return 0;
 }
 
+static int bs_sg_init(struct scsi_lu *lu)
+{
+	/*
+	 * Setup struct scsi_lu->cmd_perform() passthrough pointer
+	 * (if available) for the underlying device type.
+	 */
+	lu->cmd_perform = &target_cmd_perform_passthrough;
+	if (!(lu->cmd_perform)) {
+		eprintf("Unable to locate lu->cmd_perform() for bs_sg\n");
+		return -1;
+	}
+	/*
+	 * Setup struct scsi_lu->cmd_done() passthrough pointer using
+	 * usr/target.c:__cmd_done_passthrough().
+	 */
+	lu->cmd_done = &__cmd_done_passthrough;
+	return 0;
+}
+
 static int bs_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
 {
 	int sg_fd, err;
@@ -238,6 +257,7 @@ static int bs_sg_cmd_done(struct scsi_cmd *cmd)
 static struct backingstore_template sg_bst = {
 	.bs_name		= "sg",
 	.bs_datasize		= 0,
+	.bs_init		= bs_sg_init,
 	.bs_open		= bs_sg_open,
 	.bs_close		= bs_sg_close,
 	.bs_cmd_submit		= bs_sg_cmd_submit,
Signature · 1 line
1.5.6.5