Re: [PATCH] tgt-admin bs-type support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tomasz Chmielewski wrote:
Chris Boot wrote:
All,

I wanted to play with different backing store types on iSCSI targets, but keep using tgt-admin and /etc/tgt/targets.conf. I noticed tgt-admin didn't have a way of setting the bs type, so here's a patch to let it do it.

Looks OK - but please also add example usage to doc/targets.conf.example.

Thanks for the feedback. Indeed that would make sense! I've added a couple of lines to the file - one as a proper example on one of the targets (but commented out) and another in the list of parameters with a few words to describe the new parameter. Hope it's up to scratch!

Again, apologies for the attachment.

Signed-off-by: Chris Boot <bootc@xxxxxxxxx>

Cheers,
Chris
diff -durpN tgt-0.9.10.orig/doc/targets.conf.example tgt-0.9.10/doc/targets.conf.example
--- tgt-0.9.10.orig/doc/targets.conf.example	2009-10-24 02:13:04.000000000 +0100
+++ tgt-0.9.10/doc/targets.conf.example	2009-11-12 11:09:32.000000000 +0000
@@ -113,6 +113,7 @@ default-driver iscsi
 	vendor_id back2
 	#mode_page 8:0:18:0x10:0:0xff....
 	#mode_page 8:0:18:0x10:0:0xff....
+	#bs-type aio
 	lun 15
     </backing-store>
 
@@ -129,6 +130,7 @@ default-driver iscsi
     #mode_page 8:0:18:0x10:0:0xff....
     #mode_page 8:0:18:0x10:0:0xff....
     #device-type ...
+    #bs-type ...	# backing store type - default rdwr, can be aio, mmap, etc...
     #allow-in-use yes	# if specified globally, can't be overwritten locally
 
     write-cache off
diff -durpN tgt-0.9.10.orig/scripts/tgt-admin tgt-0.9.10/scripts/tgt-admin
--- tgt-0.9.10.orig/scripts/tgt-admin	2009-10-24 02:13:04.000000000 +0100
+++ tgt-0.9.10/scripts/tgt-admin	2009-11-12 09:26:08.000000000 +0000
@@ -392,6 +392,7 @@ sub add_backing_direct {
 	if (-e $backing_store && ! -d $backing_store && $can_alloc == 1) {
 		my @exec_commands;
 		my $device_type;
+		my $bs_type;
 		my %luns;
 		my @added_luns;
 		# Find out LUNs which are "reserved" in the config file
@@ -429,6 +430,10 @@ sub add_backing_direct {
 							$device_type = $result;
 							$params_added{$store_option} = 1;
 						}
+						if ($store_option eq "bs-type") {
+							$bs_type = $result;
+							$params_added{$store_option} = 1;
+						}
 						if ($store_option eq "mode_page") {
 							@mode_page = @$result;
 							foreach my $mode_page (@mode_page) {
@@ -514,6 +519,11 @@ sub add_backing_direct {
 				check_if_hash_array($$target_options_ref{"device-type"}, "device-type");
 				$device_type = $$target_options_ref{"device-type"};
 			}
+			# bs-type
+			if ($params_added{"bs-type"} ne 1) {
+				check_if_hash_array($$target_options_ref{"bs-type"}, "bs-type");
+				$bs_type = $$target_options_ref{"bs-type"};
+			}
 			# lun
 			if (length $$target_options_ref{"lun"}) {
 				check_if_hash_array($$target_options_ref{"lun"}, "lun");
@@ -526,7 +536,8 @@ sub add_backing_direct {
 		}
 		# Execute commands for a given LUN
 		if (length $device_type) { $device_type = "--device-type $device_type" };
-		execute("tgtadm --lld $driver --op new --mode logicalunit --tid $next_tid --lun $lun -b $backing_store $device_type");
+		if (length $bs_type) { $bs_type = "--bstype $bs_type" };
+		execute("tgtadm --lld $driver --op new --mode logicalunit --tid $next_tid --lun $lun -b $backing_store $device_type $bs_type");
 		foreach my $exec_command (@exec_commands) {
 			if (length $exec_command) { execute($exec_command) }
 		}

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux