[PATCH] tgt-admin bs-type support

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

 



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.

I haven't submitted a patch to a project for a little while so please hold my hand on this one! :-) Also, I've had to attach it since I can't figure out how to get Thunderbird to preserve tabs.

I'm not subscribed to this list, so please CC me when replying.

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

Cheers,
Chris
--- tgt-admin.orig	2009-11-12 09:20:18.000000000 +0000
+++ tgt-admin	2009-11-12 09:26:08.000000000 +0000
@@ -392,6 +392,7 @@
 	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 @@
 							$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 @@
 				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 @@
 		}
 		# 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