aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2017-09-18 19:15:01 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2017-09-18 19:15:01 +0000
commit3c285acb6d8f2bf346f50ee4e3ebe878e07e2c33 (patch)
tree645885630ab780e2371bc219ba9ee843f18c421b /scripts
parent3e3bb389c5718f595a07cd0a51ccd0162713f44f (diff)
downloadsg3_utils-3c285acb6d8f2bf346f50ee4e3ebe878e07e2c33.tar.gz
https://github.com/hreinecke/sg3_utils branch sles15 synced 20170914; change sg_ll_*() function's 'int noisy' to bool
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@715 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'scripts')
-rw-r--r--scripts/40-usb-blacklist.rules10
-rw-r--r--scripts/55-scsi-sg3_id.rules14
-rw-r--r--scripts/59-fc-wwpn-id.rules17
-rw-r--r--scripts/59-scsi-cciss_id.rules18
-rwxr-xr-xscripts/cciss_id66
-rw-r--r--scripts/fc_wwpn_id49
-rw-r--r--scripts/lunmask.service11
-rwxr-xr-xscripts/rescan-scsi-bus.sh25
8 files changed, 201 insertions, 9 deletions
diff --git a/scripts/40-usb-blacklist.rules b/scripts/40-usb-blacklist.rules
new file mode 100644
index 00000000..fd821f1e
--- /dev/null
+++ b/scripts/40-usb-blacklist.rules
@@ -0,0 +1,10 @@
+#
+# Blacklist specific USB devices
+#
+# don't inquire sn and di on broken devices (https://bugzilla.suse.com/show_bug.cgi?id=840054)
+
+# unkown device
+ATTRS{idVendor}=="0aec", ATTRS{idProduct}=="3260", ENV{ID_SCSI_DI}="1"
+# Sony/JMicron port replicator
+ATTRS{idVendor}=="054c", ATTRS{idProduct}=="06a0", ENV{ID_SCSI_DI}="1"
+
diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules
index 8c7356b8..4975bc53 100644
--- a/scripts/55-scsi-sg3_id.rules
+++ b/scripts/55-scsi-sg3_id.rules
@@ -11,7 +11,10 @@ ENV{DEVTYPE}=="partition", IMPORT{parent}="SCSI_*", ENV{ID_SCSI}="1"
# 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"
+# Set 'ID_SCSI_INQUIRY=0' in an earlier udev rule if the kernel
+# fails to scan VPD pages correctly; the rules will then fall
+# back to calling sg_vpd directly.
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI_INQUIRY}!="?*", IMPORT{program}="/usr/bin/sg_inq --export --inhex=/sys/block/$kernel/device/inquiry --raw", ENV{ID_SCSI}="1", ENV{ID_SCSI_INQUIRY}="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}"
@@ -21,11 +24,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", 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"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}=="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_INQUIRY}!="1", IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode"
# SCSI EVPD page 0x83 values
-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"
+KERNEL=="sd*[!0-9]", ENV{ID_SCSI}=="1", ENV{ID_SCSI_INQUIRY}=="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_INQUIRY}!="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}"
@@ -48,4 +51,5 @@ ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{ID_BUS}="scsi", ENV{ID
ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="1$env{SCSI_IDENT_LUN_T10}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_T10}"
ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA_LOCAL}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA_LOCAL}"
ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_VENDOR}"
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_SERIAL}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_SERIAL}"
LABEL="sg3_utils_id_end"
diff --git a/scripts/59-fc-wwpn-id.rules b/scripts/59-fc-wwpn-id.rules
new file mode 100644
index 00000000..81a20ad2
--- /dev/null
+++ b/scripts/59-fc-wwpn-id.rules
@@ -0,0 +1,17 @@
+#
+# FC WWPN-based by-path links
+#
+
+ACTION!="add|change", GOTO="fc_wwpn_end"
+KERNEL!="sd*", GOTO="fc_wwpn_end"
+
+ENV{DEVTYPE}=="disk", IMPORT{program}="fc_wwpn_id %p"
+ENV{DEVTYPE}=="partition", IMPORT{parent}="FC_*"
+ENV{FC_TARGET_WWPN}!="$*"; GOTO="fc_wwpn_end"
+ENV{FC_INITIATOR_WWPN}!="$*"; GOTO="fc_wwpn_end"
+ENV{FC_TARGET_LUN}!="$*"; GOTO="fc_wwpn_end"
+
+ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-path/fc-$env{FC_INITIATOR_WWPN}-$env{FC_TARGET_WWPN}-lun-$env{FC_TARGET_LUN}"
+ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-path/fc-$env{FC_INITIATOR_WWPN}-$env{FC_TARGET_WWPN}-lun-$env{FC_TARGET_LUN}-part%n"
+
+LABEL="fc_wwpn_end"
diff --git a/scripts/59-scsi-cciss_id.rules b/scripts/59-scsi-cciss_id.rules
new file mode 100644
index 00000000..4eb4561e
--- /dev/null
+++ b/scripts/59-scsi-cciss_id.rules
@@ -0,0 +1,18 @@
+# cciss compat rules
+
+ACTION!="add|change", GOTO="cciss_compat_end"
+KERNEL!="sd*", GOTO="cciss_compat_end"
+ENV{ID_VENDOR}!="HP", ENV{ID_VENDOR}!="COMPAQ", GOTO="cciss_compat_end"
+ENV{ID_MODEL}!="LOGICAL_VOLUME", GOTO="cciss_compat_end"
+
+ENV{DEVTYPE}=="disk", DRIVERS=="hpsa", IMPORT{program}="cciss_id %p"
+ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
+ENV{ID_CCISS}!="?*", GOTO="cciss_compat_end"
+
+ENV{DEVTYPE}=="disk", SYMLINK+="cciss/$env{ID_CCISS}"
+ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/cciss-$env{ID_SERIAL}"
+
+ENV{DEVTYPE}=="partition", SYMLINK+="cciss/$env{ID_CCISS}p%n"
+ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/cciss-$env{ID_SERIAL}-part%n"
+
+LABEL="cciss_compat_end"
diff --git a/scripts/cciss_id b/scripts/cciss_id
new file mode 100755
index 00000000..8ac11d5f
--- /dev/null
+++ b/scripts/cciss_id
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# cciss_id
+#
+# Generates device node names according to the cciss naming rules
+#
+# Copyright (C) 2011 SUSE Linux Products GmbH
+# Author:
+# Hannes Reinecke <hare@suse.de>
+#
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation version 2 of the License.
+#
+# This script generates a device node name which is compatible
+# with the 'cciss' device naming rules.
+# It is intended to provide backward-compatible names for the
+# 'hpsa' driver.
+#
+
+cciss_enumerate()
+{
+ local last_pci_dev=${1##0000:}
+ local cur_pci_dev
+ local cciss_num=0
+
+ for cur_pci_dev in $(lspci -n | tac | sed -n 's/\(..:..\..\) .* 103c:\(3220\|3230\|3238\|323a\|323b\) .*/\1/p') ; do
+ if [ "$cur_pci_dev" == "$last_pci_dev" ] ; then
+ echo "$cciss_num"
+ return;
+ fi
+ cciss_num=$(($cciss_num + 1))
+ done
+ echo "$cciss_num"
+}
+
+hpsa_lun_offset()
+{
+ local scsi_host=$1
+
+ scsi_id=$(lsscsi 2>/dev/null | sed -n "s/.\(${scsi_host}:[0-9]*:[0-9]*:[0-9]*\)..*disk .*/\1/p" | head -1)
+ echo ${scsi_id##*:}
+}
+
+DEVPATH=$1
+SCSIPATH=$(cd -P /sys$DEVPATH/device; echo $PWD)
+SCSIID=${SCSIPATH##*/}
+HOSTID=${SCSIID%%:*}
+LUNID=${SCSIID##*:}
+PCIPATH=${SCSIPATH%%/host*}
+PCIDEV=${PCIPATH##*/}
+HOSTPATH=${PCIPATH}/host${HOSTID}/scsi_host/host${HOSTID}
+read controller 2>/dev/null <${HOSTPATH}/ctlr_num || controller=$(cciss_enumerate $PCIDEV)
+
+# hpsa lies about the LUN ...
+disk_offset=$(hpsa_lun_offset $HOSTID)
+if [ "$disk_offset" ] ; then
+ disk=$(( $LUNID - $disk_offset ))
+else
+ disk=$LUNID
+fi
+
+if [ "$controller" ] && [ "$disk" ] ; then
+ echo "ID_CCISS=c${controller}d${disk}"
+fi
diff --git a/scripts/fc_wwpn_id b/scripts/fc_wwpn_id
new file mode 100644
index 00000000..c8d01892
--- /dev/null
+++ b/scripts/fc_wwpn_id
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# fc_wwpn_id
+#
+# Generates device node names links based on FC WWPN
+# Copyright (c) 2016 Hannes Reinecke, SUSE Linux GmbH
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation version 2 of the License.
+#
+
+DEVPATH=$1
+SCSIPATH=$(cd -P "/sys$DEVPATH/device" || exit; echo "$PWD")
+
+d=$SCSIPATH
+[ -d "$d/scsi_disk" ] || exit 0
+target_lun=${d##*:}
+
+while [ -n "$d" ] ; do
+ d=${d%/*}
+ e=${d##*/}
+ case "$e" in
+ rport*)
+ rport=$e
+ rport_dir="/sys/class/fc_remote_ports/$rport"
+ if [ -d "$rport_dir" ] ; then
+ rport_wwpn=$(cat "$rport_dir/port_name")
+ fi
+ ;;
+ host*)
+ host=$e
+ host_dir="/sys/class/fc_host/$host"
+ if [ -d "$host_dir" ] ; then
+ host_wwpn=$(cat "$host_dir/port_name")
+ break;
+ fi
+ esac
+done
+
+echo "FC_TARGET_LUN=$target_lun"
+
+if [ -n "$rport_wwpn" ] ; then
+ echo "FC_TARGET_WWPN=$rport_wwpn"
+fi
+
+if [ -n "$host_wwpn" ] ; then
+ echo "FC_INITIATOR_WWPN=$host_wwpn"
+fi
diff --git a/scripts/lunmask.service b/scripts/lunmask.service
new file mode 100644
index 00000000..03fdd96a
--- /dev/null
+++ b/scripts/lunmask.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Disable LUN masking and scan SCSI Hosts
+After=systemd-udev-trigger.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/lib/systemd/scripts/scsi-enable-target-scan.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index fad4868d..bbe22283 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -715,7 +715,16 @@ searchexisting()
else
match=1
fi
- test $match -eq 1 && doreportlun
+
+ test $match -eq 0 && continue
+
+ if [ -z "$lunsearch" ] ; then
+ doreportlun
+ else
+ for lun in $lunsearch ; do
+ dolunscan
+ done
+ fi
done
}
@@ -993,7 +1002,7 @@ flushmpaths()
# Find resized luns
findresized()
{
- local devs=`ls /sys/class/scsi_device/`
+ local devs=
local size=
local new_size=
local sysfs_path=
@@ -1003,6 +1012,14 @@ findresized()
local mpathsize=
declare -a mpathsizes
+ if [ -z "$lunsearch" ] ; then
+ devs=`ls /sys/class/scsi_device/`
+ else
+ for lun in $lunsearch ; do
+ devs="$devs `(cd /sys/class/scsi_device/ && ls -d *:${lun})`"
+ done
+ fi
+
for hctl in $devs ; do
sysfs_path="/sys/class/scsi_device/$hctl/device"
if [ -d "$sysfs_path/block" ] ; then
@@ -1070,8 +1087,8 @@ if test @$1 = @--help -o @$1 = @-h -o @$1 = @-?; then
echo "--channels=LIST: Scan only channel(s) in LIST"
echo "--color: use coloured prefixes OLD/NEW/DEL"
echo "--flush: same as -f"
- echo "--forceremove: Remove and readd every device (DANGEROUS)"
- echo "--forcerescan: Rescan existing devices"
+ echo "--forceremove: Remove stale devices (DANGEROUS)"
+ echo "--forcerescan: Remove and readd existing devices (DANGEROUS)"
echo "--help: print this usage message then exit"
echo "--hosts=LIST: Scan only host(s) in LIST"
echo "--ids=LIST: Scan only target ID(s) in LIST"