[stgt] targets.conf problem, setting up tape drives

Tomasz Chmielewski mangoo at wpkg.org
Mon Oct 26 14:25:11 CET 2009


Albert Pauw wrote:

> yes, that was exactly it. I wasn't aware of the allow-in-use option, but 
> it works.
> 
> Now the only other thing left is the multiple element_type stuff used 
> for the changer device.

Could you try this patch?

Config should look like this:

<target iqn.2008-09.com.example:server.changer>
backing-store /mnt/1/notape
device-type changer
params element_type=1,start_address=1,quantity=1,media_home=/root/tapes
params element_type=2,start_address=1000,quantity=24,media_home=/root/tapes
params element_type=3,start_address=10,quantity=5,media_home=/root/tapes
(...)



Signed-off-by: Tomasz Chmielewski <mangoo at wpkg.org>

--- /usr/sbin/tgt-admin.orig	2009-10-26 12:02:55.000000000 +0100
+++ /usr/sbin/tgt-admin	2009-10-26 14:08:36.000000000 +0100
@@ -346,6 +346,10 @@
 	    $param eq "path" || $param eq "mode_page") {
 		return("tgtadm --lld $driver --op update --mode logicalunit --tid $next_tid --lun=$lun --params $param=\"$param_value\"");
 	}
+	if ($param eq "params") {
+		return("tgtadm --lld $driver --op update --mode logicalunit --tid $next_tid --lun=$lun --params \"$param_value\"");
+
+	}
 }
 
 # Find next available LUN
@@ -378,7 +382,6 @@
 sub add_backing_direct {
 	my $backing_store = $_[0];
 	my $target_options_ref = $_[1];
-	my $lun;
 	my $data_key_ref = $_[2];
 	my $direct_store = $_[3];
 	my $driver = $$target_options_ref{"driver"};
@@ -407,15 +410,24 @@
 		if (ref $value eq "HASH") {
 			my %params_added;
 			my @mode_page;
+			my @params;
 			foreach my $store (keys %$value) {
+				# lun
+				if (length $$target_options_ref{"lun"}) {
+					check_if_hash_array($$target_options_ref{"lun"}, "lun");
+					$lun = $$target_options_ref{"lun"};
+				}
+
 				if (ref $$value{$store} eq "HASH" && $store eq $backing_store) {
 					foreach my $store_option (keys %{$$value{$store}}) {
 						my $result = $$value{$store}{$store_option};
 						check_value($result);
-						if ($store_option ne "mode_page") { check_if_hash_array($result,$store_option) }
+						if ($store_option ne "mode_page" && $store_option ne "params")
+							{ check_if_hash_array($result,$store_option) }
 						# write-cache can be set globally per target and overridden per lun,
 						# so we treat it differently
-						if ($store_option ne "mode_page" && $store_option ne "write-cache") {
+						if ($store_option ne "mode_page" && $store_option ne "write-cache"
+							&& $store_option ne "params") {
 							my $exec_command = add_params($store_option, $result, $lun, $driver);
 							push(@exec_commands, $exec_command);
 							$params_added{$store_option} = 1;
@@ -430,9 +442,22 @@
 							$params_added{$store_option} = 1;
 						}
 						if ($store_option eq "mode_page") {
+							unless (ref($result) eq 'ARRAY') {
+								$result = [ $result ];
+							}
 							@mode_page = @$result;
 							foreach my $mode_page (@mode_page) {
-								my $exec_command = add_params("mode_page", $mode_page, $lun, $driver);
+								my $exec_command = add_params($store_option, $mode_page, $lun, $driver);
+								push(@exec_commands, $exec_command);
+							}
+						}
+						if ($store_option eq "params") {
+							unless (ref($result) eq 'ARRAY') {
+								$result = [ $result ];
+							}
+							@params = @$result;
+							foreach my $param (@params) {
+								my $exec_command = add_params($store_option, $param, $lun, $driver);
 								push(@exec_commands, $exec_command);
 							}
 						}
@@ -509,16 +534,21 @@
 					push(@exec_commands, $exec_command);
 				}
 			}
+			# params
+			unless (ref($$target_options_ref{params}) eq 'ARRAY') {
+				$$target_options_ref{params} = [ $$target_options_ref{params} ];
+			}
+			foreach my $param (@{$$target_options_ref{"params"}}) {
+				if (length $param) {
+					my $exec_command = add_params("params", $param, $lun, $driver);
+					push(@exec_commands, $exec_command);
+				}
+			}
 			# device-type
 			if ($params_added{"device-type"} ne 1) {
 				check_if_hash_array($$target_options_ref{"device-type"}, "device-type");
 				$device_type = $$target_options_ref{"device-type"};
 			}
-			# lun
-			if (length $$target_options_ref{"lun"}) {
-				check_if_hash_array($$target_options_ref{"lun"}, "lun");
-				$lun = $$target_options_ref{"lun"};
-			}
 		} else {
 			print "If you got here, this means your config file is not supported.\n";
 			print "Please report it to stgt mailing list and attach your config files.\n";
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list