diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2016-05-11 20:20:52 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2016-05-11 20:20:52 +0000 |
commit | 5f3a67ec3caf126f48263a8d392e83e7e99c8ba2 (patch) | |
tree | 7361495943e2978a8b168fd46f7ac26a3b9ec02e /scripts | |
parent | eaf62d70e3afbd384d1b626979eb39b2854bfb7a (diff) | |
download | sg3_utils-5f3a67ec3caf126f48263a8d392e83e7e99c8ba2.tar.gz |
rescan-scsi-bus.sh + 55-scsi-sg3_id.rules: fixes from HR at Suse
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@703 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/55-scsi-sg3_id.rules | 15 | ||||
-rwxr-xr-x | scripts/rescan-scsi-bus.sh | 46 |
2 files changed, 35 insertions, 26 deletions
diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules index e914a5dd..8c7356b8 100644 --- a/scripts/55-scsi-sg3_id.rules +++ b/scripts/55-scsi-sg3_id.rules @@ -7,7 +7,12 @@ SUBSYSTEM!="block", GOTO="sg3_utils_id_end" # Import values for partitions ENV{DEVTYPE}=="partition", IMPORT{parent}="SCSI_*", ENV{ID_SCSI}="1" # SCSI INQUIRY values -KERNEL=="sd*[!0-9]|sr*", IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1" +# If the 'inquiry' sysfs attribute is present the kernel will already +# have scanned for VPD pages, so if the vpd page attribute is not +# present it is not supported (or deemed unsafe to access). +# Hence we can skip the call to sg_inq and avoid I/O altogether. +KERNEL=="sd*[!0-9]|sr*", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/inquiry --raw", ENV{ID_SCSI}="1", ENV{ID_SCSI_SN}="1", ENV{ID_SCSI_DI}="1" +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}!="1", IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1" # scsi_id compat mappings ENV{SCSI_VENDOR}=="?*", ENV{ID_VENDOR}="$env{SCSI_VENDOR}" ENV{SCSI_VENDOR_ENC}=="?*", ENV{ID_VENDOR_ENC}="$env{SCSI_VENDOR_ENC}" @@ -16,11 +21,11 @@ ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}" ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}" ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}" # SCSI EVPD page 0x80 values -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw", ENV{ID_SCSI_SN}="1" -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_SN}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode", ENV{ID_SCSI_SN}="1" +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_SN}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg80 --raw" +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_SN}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode" # SCSI EVPD page 0x83 values -KERNEL=="sd*[!0-9]", ENV{ID_SCSI}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg83 --raw", ENV{ID_SCSI_DI}="1" -KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_DI}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode", ENV{ID_SCSI_DI}="1" +KERNEL=="sd*[!0-9]", ENV{ID_SCSI}=="1", ENV{ID_SCSI_DI}=="1", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/vpd_pg83 --raw" +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_DI}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode" # ID_WWN compat mapping ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA_REGEXT}" diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh index 80a9ae05..fad4868d 100755 --- a/scripts/rescan-scsi-bus.sh +++ b/scripts/rescan-scsi-bus.sh @@ -4,7 +4,7 @@ # (c) 2006--2015 Hannes Reinecke, GNU GPL v2 or later # $Id: rescan-scsi-bus.sh,v 1.57 2012/03/31 14:08:48 garloff Exp $ -VERSION="20160228" +VERSION="20160511" SCAN_WILD_CARD=4294967295 setcolor () @@ -360,37 +360,37 @@ chanlist () # Returns the list of existing targets per host idlist () { - local hcil - local target local tmpid local newid - - idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq) - echo "${channel} - -" > /sys/class/scsi_host/host${host}/scan - # Rescan to check if we found new targets - newsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq) - for id in $newsearch ; do - newid=$id - for tmpid in $idsearch ; do - if test $id -eq $tmpid ; then - newid= + local oldid + + oldlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) + # Rescan LUN 0 to check if we found new targets + echo "${channel} - 0" > /sys/class/scsi_host/host${host}/scan + newlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) + for newid in $newlist ; do + oldid=$newid + for tmpid in $oldlist ; do + if test $newid = $tmpid ; then + oldid= break fi done - if test -n "$newid" ; then - id=$newid - for dev in /sys/class/scsi_device/${host}:${channel}:${newid}:* ; do - [ -d $dev ] || continue; - hcil=${dev##*/} - lun=${hcil##*:} + if test -n "$oldid" ; then + id=${oldid%%:*} + lun=${oldid##*:} + dev=/sys/class/scsi_device/${host}:${channel}:${id}:${lun} + if [ -d $dev ] ; then + hcil=${dev##*/} printf "\r${green}NEW: $norm" testexist if test "$SCSISTR" ; then incrfound "$hcil" fi - done + fi fi done + idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq) } # Returns the list of existing LUNs from device $host $channel $id $lun @@ -642,7 +642,11 @@ dosearch () fi for channel in $channelsearch; do if test -z "$idsearch" ; then - idlist + if test -z "$lunsearch" ; then + idlist + else + idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq) + fi fi for id in $idsearch; do if test -z "$lunsearch" ; then |