[Stgt-devel] Initial patch to add Tape and Library support

FUJITA Tomonori fujita.tomonori
Thu Mar 22 16:54:10 CET 2007


From: "Mark Harvey" <markh794 at gmail.com>
Subject: [Stgt-devel] Initial patch to add Tape and Library support
Date: Thu, 22 Mar 2007 13:37:57 +1100

> Sorry for the 'attachment' but it seems a little too big to include in-line.
> 
> I can chop it up if requested.
> 
> Note: Most (read all except Inquiry) commands are not supported yet.

diff -urN -x TAGS -x .svn reference/doc/README.vtl vtl/doc/README.vtl
--- reference/doc/README.vtl	1970-01-01 10:00:00.000000000 +1000
+++ vtl/doc/README.vtl	2007-03-22 10:57:24.000000000 +1100
@@ -0,0 +1,35 @@
+Initial support for SCSI Streaming and SCSI Medium Changer devices.
+markh794 at gmail dot com
+mark_harvey at symantec dot com
+
+
+To set up a changer and tape device..
+./usr/tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2007-03:marks-vtl_smc:`hostname` --target-type changer
+./usr/tgtadm --lld iscsi --op new --mode target --tid 2 -T iqn.2007-03:marks-vtl_ssc:`hostname` --target-type tape
+
+I'm hijacking the 'backing device' for use as the configuration file.

This isn't a good idea. tgt doesn't use any configuration files (or
database). Everything should be configured via tgtadm. We leave
storing configurations to other projects like Openfiler.


diff -urN -x TAGS -x .svn reference/usr/target.c vtl/usr/target.c
--- reference/usr/target.c	2007-03-20 08:06:54.000000000 +1100
+++ vtl/usr/target.c	2007-03-22 05:43:28.000000000 +1100
@@ -37,7 +37,7 @@
 #include "tgtadm.h"
 
 extern struct device_type_template sbc_template, mmc_template, osd_template,
-	spt_template;
+			ssc_template, smc_template, spt_template;
 
 static LIST_HEAD(target_list);
 
@@ -239,11 +239,16 @@
 
 	snprintf(device->scsi_id, sizeof(device->scsi_id),
 		 "deadbeaf%d:%" PRIu64, tid, lun);
+	snprintf(device->scsi_sn, sizeof(device->scsi_sn),
+		 "beaf%d%" PRIu64, tid, lun);
 
 	tgt_cmd_queue_init(&device->cmd_queue);
 
-	if (target->dev_type_template.device_init)
-		target->dev_type_template.device_init(device);
+	if(target->dev_type_template.device_init) {
+		err = target->dev_type_template.device_init(device);
+		if(err)
+			return err;
+	}

We need to kill a new target that has been already created. I'll take
care about it.

 
@@ -259,6 +264,7 @@
 {
 	struct target *target;
 	struct tgt_device *device;
+	int	err;
 
 	dprintf("%u %" PRIu64 "\n", tid, lun);
 
@@ -271,12 +277,17 @@
 	if (!list_empty(&device->cmd_queue.queue))
 		return TGTADM_LUN_ACTIVE;
 
+	err = target->dev_type_template.device_shutdown(device);
+
 	free(device->path);
 	list_del(&device->device_siblings);
 
 	target->bst->bs_close(device);
 	free(device);
-	return 0;
+	if(err)
+		return err;
+	else
+		return 0;

ditto.
 



More information about the stgt mailing list