Re: SCSI ID uniqueness: VMware initiator

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

 



Hi Fujita,

thanks for your response, much appreciated. Please see below.

    Yaron

On 10/25/2012 07:46 AM, FUJITA Tomonori wrote:
[...]
* target name needs to be globally unique.

Trying to work around the issue, we attempted to set the SCSI ID
parameter for the LUN using this command: tgtadm --mode logicalunit
--op update --tid $tid --lun $lun --params scsi_id="my id"


* This syntax is undocumented. Can you please add it to the man page? Or
* can I provide such a patch?
Please send the patch. I'll merge it.

Attached.
[...]
Finally we just randomized the target ID value, which causes tgtadm to
generate a somewhat randomized SCSI ID, and makes VMware happy. We
also patched tgt-admin to dump the tid value and accept it back in its
"execute" mode. I will gladly share this patch, but I suspect that it
is the wrong thing to do from an architectural POV. Any opinions?
scsi id is supposed to be parsistent after reboot. We can't use random
values every time.
Sure, we persist the configuration (*including* the tid value) with the patched tgt-admin. The SCSI_ID is derived from the tid, so it does not change after reboot. It would have been better to persist SCSI_ID directly, but then we would have to change the format of the tgt-admin config file rather drastically. The format is extensible enough to support per-target parameters, but not per-LUN parameters.

I am attaching the tgt-admin patch, although I don't think it is the "right" way of solving this problem.

--

*Yaron Sheffer*|Co-Founder and CTO, *Porticor Cloud Security*| T:+972 73 7294673 <tel:+972-73-7294673> | M:+972 52 8698984 <tel:+972-52-8698984> | yaronf@xxxxxxxxxxxx <mailto:yaronf@xxxxxxxxxxxx> |www.porticor.com <http://www.porticor.com/>

--- tgtadm.8.xml.orig	2012-10-25 10:41:40.084644261 +0200
+++ tgtadm.8.xml	2012-10-25 10:44:59.780445905 +0200
@@ -172,7 +172,15 @@
       <varlistentry><term><option>--lld &lt;driver&gt; --op update --mode target --tid &lt;id&gt; --params parameter=value&lt;,...&gt;</option></term>
         <listitem>
           <para>
-	    Sets/changes the value of one or more parameters.
+	    Sets/changes the value of one or more target parameters.
+          </para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry><term><option>--lld &lt;driver&gt; --op update --mode logicalunit --tid &lt;id&gt; --lun &lt;id&gt; --params parameter=value&lt;,...&gt;</option></term>
+        <listitem>
+          <para>
+	    Sets/changes the value of one or more logical unit parameters.
           </para>
         </listitem>
       </varlistentry>
--- /usr/sbin/tgt-admin.orig	2012-10-15 08:28:00.932922867 -0700
+++ tgt-admin	2012-10-16 07:02:17.448209072 -0700
@@ -35,6 +35,7 @@
   -p, --pretend			only print tgtadm options
       --dump			dump current tgtd configuration (note: does not
 				include detailed parameters, like write caching)
+      --fix-tid			dump (and respectfully, restore) the target's TID
   -v, --verbose			increase verbosity (show tgtadm commands)
   -h, --help			show this help
 
@@ -53,6 +54,7 @@
 my $alternate_conf="0";
 my $ignore_errors = 0;
 my $force = 0;
+my $fix_tid = 0;
 my $pretend = 0;
 my $dump = 0;
 my $verbose = 0;
@@ -66,6 +68,7 @@
 	"s|show"        => \$show,
 	"c|conf=s"      => \$alternate_conf,
 	"ignore-errors" => \$ignore_errors,
+	"fix-tid"	=> \$fix_tid,
 	"f|force"       => \$force,
 	"p|pretend"     => \$pretend,
 	"dump"          => \$dump,
@@ -200,8 +203,10 @@
 					{
 					# We have to find available tid
 					if ($in_configfile == 1 && $configured == 0 && $pretend == 0) {
-						my $maxtid = find_max_tid();
-						$next_tid = $maxtid + 1;
+						if ($fix_tid == 0) {
+							my $maxtid = find_max_tid();
+							$next_tid = $maxtid + 1;
+						}
 					} elsif (length $single_target && $configured == 1) {
 						$next_tid = $tgtadm_output_tid{$target};
 					} else {
@@ -226,12 +231,22 @@
 					if (not defined $target_options{"driver"}) {
 						$target_options{"driver"} = $default_driver;
 					}
+					if ($fix_tid == 1) {
+						if (not defined $target_options{"tid"}) {
+							print "Running in fix-tid mode, but tid not defined";
+							exit 1;
+						}
+						$next_tid = $target_options{"tid"};
+					}
 					my $driver = $target_options{"driver"};
 					execute("# Adding target: $target");
 					execute("tgtadm --lld $driver --op new --mode target --tid $next_tid -T $target");
 					foreach my $k3 (sort keys %{$conf{$k}{$k2}}) {
 						$option = $k3;
 						$value = $conf{$k}{$k2}{$k3};
+						if ($option eq "tid") {
+							next;
+						}
 						check_value($value);
 						process_options($target_options_ref,$data_key);
 						# If there was no option called "initiator-address", it means
@@ -752,6 +767,10 @@
 		my $target_name = show_target_info($current_target, "target_name");
 		print "<target $target_name>\n";
 
+		if ($fix_tid == 1) {
+			print "\ttid " . $tgtadm_output_tid{$target_name} . "\n";
+		}
+
 		if (scalar @drivers_combined_uniq gt 1) {
 			my $driver = show_target_info($current_target, "driver");
 			print "\tdriver $driver\n";

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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

  Powered by Linux