File s390-tools-sles11sp2-lsluns-check-scsi-registration-in-loop-after-unit_add.patch of Package s390-tools

Subject: [PATCH] [BZ 82673] lsluns: Check SCSI registration in loop, after LUN0&WLUN unit_add
From: Seshagiri N Ippili <seshagiri.ippili@in.ibm.com>

Description:  lsluns: Check SCSI registration in loop, after LUN0&WLUN unit_add
Symptom:      lsluns fails to recognize LUN0 & WLUN attachement with error
              message "Cannot attach WLUN / LUN0 for scanning".
Problem:      SCSI device is not available immediately after the unit_add.
Solution:     Check for SCSI registration multiple times, after LUN0 & WLUN
              attached via unit_add, to allow SCSI mid layer to complete SCSI
              device registration.
Reproduction: Execute lsluns on slow probe response storages.
Problem-ID:   82673
---
 zconf/lsluns |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

--- a/zconf/lsluns
+++ b/zconf/lsluns
@@ -25,13 +25,21 @@ my $active = "";
 my $wlun = "0xc101000000000000";
 my $lun0 = "0x0000000000000000";
 my $sg_dir = "/sys/class/scsi_generic";
+my $udevsettle_call;
+my $udevadm = "/sbin/udevadm";
 
 
+if (! -e $udevadm) {
+        $udevsettle_call = "/sbin/udevsettle";
+} else {
+        $udevsettle_call = "$udevadm settle";
+}
 sub list_luns
 {
     my %lun_hash = get_lun_hash();
     my $drv_dir = "/sys/bus/ccw/drivers/zfcp";
     my $man_att;
+    my $cnt;
 
     foreach my $a (sort keys %res_hash) {
         print "Scanning for LUNs on adapter $a\n";
@@ -47,13 +55,21 @@ sub list_luns
             }
             if (!defined($lun_hash{$a}{$p})) {
                 `echo $lun0 >> $drv_dir/$a/$p/unit_add 2>/dev/null`;
-                select(undef, undef, undef, 0.1);
-                %lun_hash = get_lun_hash();
+                for ($cnt = 0; $cnt < 4; $cnt++) {
+                    `$udevsettle_call`;
+                    %lun_hash = get_lun_hash();
+                    last if (defined($lun_hash{$a}{$p}));
+                    select(undef, undef, undef, 0.1);
+                }
                 if (!defined($lun_hash{$a}{$p})) {
                     `echo $lun0 >> $drv_dir/$a/$p/unit_remove 2>/dev/null`;
                     `echo $wlun >> $drv_dir/$a/$p/unit_add 2>/dev/null`;
-                    select(undef, undef, undef, 0.1);
-		    %lun_hash = get_lun_hash();
+                    for ($cnt = 0; $cnt < 4; $cnt++) {
+                        `$udevsettle_call`;
+                        %lun_hash = get_lun_hash();
+                        last if (defined($lun_hash{$a}{$p}));
+                        select(undef, undef, undef, 0.1);
+                    }
                     if (!defined($lun_hash{$a}{$p})) {
                     	`echo $wlun >> $drv_dir/$a/$p/unit_remove 2>/dev/null`;
                     	print"\tat port $p:\n";
openSUSE Build Service is sponsored by