linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] [bs_sg]: Add bs_sg_init() for STGT LUN passthrough
@ 2010-06-01  8:50 Nicholas A. Bellinger
  0 siblings, 0 replies; only message in thread
From: Nicholas A. Bellinger @ 2010-06-01  8:50 UTC (permalink / raw)
  To: stgt-devel, linux-scsi, FUJITA Tomonori, Mike Christie,
	Boaz Harrosh <bharr>
  Cc: James Bottomley, Douglas Gilbert, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

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().

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 usr/bs_sg.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/usr/bs_sg.c b/usr/bs_sg.c
index 8baa480..2fcb0d2 100644
--- a/usr/bs_sg.c
+++ b/usr/bs_sg.c
@@ -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,
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-01  8:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01  8:50 [PATCH 2/2] [bs_sg]: Add bs_sg_init() for STGT LUN passthrough Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).