Blame SOURCES/BZ_1400491_rescan-scsi-bus.sh_ignore_rev_change.patch

a6e0dd
diff -Nur sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh sg3_utils-1.37/scripts/rescan-scsi-bus.sh
a6e0dd
--- sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh	2018-06-12 19:54:42.668354127 +0800
a6e0dd
+++ sg3_utils-1.37/scripts/rescan-scsi-bus.sh	2018-06-12 19:55:13.261890351 +0800
a6e0dd
@@ -273,9 +273,19 @@
a6e0dd
     return 2
a6e0dd
   fi
a6e0dd
   TMPSTR=`echo "$SCSISTR" | grep 'Vendor:'`
a6e0dd
-  if [ "$TMPSTR" != "$STR" ]; then
a6e0dd
-    echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n"
a6e0dd
-    return 1
a6e0dd
+  if test $ignore_rev -eq 0 ; then
a6e0dd
+      if [ "$TMPSTR" != "$STR" ]; then
a6e0dd
+        echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n"
a6e0dd
+        return 1
a6e0dd
+      fi
a6e0dd
+  else
a6e0dd
+      # Ignore disk revision change
a6e0dd
+      local old_str_no_rev=`echo "$TMPSTR" | sed -e 's/.\{4\}$//'`
a6e0dd
+      local new_str_no_rev=`echo "$STR" | sed -e 's/.\{4\}$//'`
a6e0dd
+      if [ "$old_str_no_rev" != "$new_str_no_rev" ]; then
a6e0dd
+        echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n"
a6e0dd
+        return 1
a6e0dd
+      fi
a6e0dd
   fi
a6e0dd
   TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p'`
a6e0dd
   NTMPSTR="$(sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//' <<<${TMPSTR})"
a6e0dd
@@ -965,6 +975,7 @@
a6e0dd
     echo "--sparselun:     Tell kernel to support sparse LUN numbering"
a6e0dd
     echo "--update:        same as -u"
a6e0dd
     echo "--resize:        same as -s"
a6e0dd
+    echo "--ignore-rev:    Ignore the revision change"
a6e0dd
     echo " Host numbers may thus be specified either directly on cmd line (deprecated) or"
a6e0dd
     echo " or with the --hosts=LIST parameter (recommended)."
a6e0dd
     echo "LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges"
a6e0dd
@@ -1016,6 +1027,7 @@
a6e0dd
 existing_targets=1
a6e0dd
 mp_enable=
a6e0dd
 declare -i scan_flags=0
a6e0dd
+ignore_rev=0
a6e0dd
 
a6e0dd
 # Scan options
a6e0dd
 opt="$1"
a6e0dd
@@ -1056,6 +1068,7 @@
a6e0dd
     -sparselun) scan_flags=$((scan_flags|0x40)) ;;
a6e0dd
     -update) update=1;;
a6e0dd
     -wide) opt_idsearch=`seq 0 15` ;;
a6e0dd
+    -ignore-rev) ignore_rev=1;;
a6e0dd
     *) echo "Unknown option -$opt !" ;;
a6e0dd
   esac
a6e0dd
   shift