diff -Nru sg3-utils-1.42/debian/changelog sg3-utils-1.42/debian/changelog --- sg3-utils-1.42/debian/changelog 2016-07-06 13:19:47.000000000 +0000 +++ sg3-utils-1.42/debian/changelog 2019-10-09 06:13:54.000000000 +0000 @@ -1,3 +1,11 @@ +sg3-utils (1.42-2ubuntu1.19.04.1) disco; urgency=medium + + * d/p/55-scsi-sg3_id.rules-ID_SERIAL-fix.patch: ID_SERIAL fix for USB + SPC-only devices in 55-scsi-sg3_id.rules (LP: #1833618) + * d/p/new-location-for-major-and-minor.patch: Fix FTBS header issue + + -- Rafael David Tinoco Wed, 09 Oct 2019 06:13:54 +0000 + sg3-utils (1.42-2ubuntu1) yakkety; urgency=medium * debian/control, debian/rules: build a sg3-udeb installer package again. diff -Nru sg3-utils-1.42/debian/patches/55-scsi-sg3_id.rules-ID_SERIAL-fix.patch sg3-utils-1.42/debian/patches/55-scsi-sg3_id.rules-ID_SERIAL-fix.patch --- sg3-utils-1.42/debian/patches/55-scsi-sg3_id.rules-ID_SERIAL-fix.patch 1970-01-01 00:00:00.000000000 +0000 +++ sg3-utils-1.42/debian/patches/55-scsi-sg3_id.rules-ID_SERIAL-fix.patch 2019-10-09 06:13:54.000000000 +0000 @@ -0,0 +1,85 @@ +Description: 55-scsi-sg3_id.rules: ID_SERIAL fix for USB SPC-only devices + +Upstream commit had changes for: + +git-svn-id: svn://localhost/trunk@703 6180dd3e-e324-4e3e-922d-17de1ae2f315 +--- + ChangeLog | 4 +++- + scripts/55-scsi-sg3_id.rules | 15 ++++++++---- + scripts/rescan-scsi-bus.sh | 46 ++++++++++++++++++++---------------- + 3 files changed, 38 insertions(+), 27 deletions(-) + +But, for this SRU, I'm backporting ONLY the changes in: + + 55-scsi-sg3_id.rules | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +Because I'm only interested in the fix for USB SPC-only devices ID_SERIAL. + +This upstream commit changes the udev rules logic for USB block devices +that only supports SCSI PRIMARY COMMANDS, not supporting SCSI INQ 0x80 +nor 0x83. + +Despite a possible delay, still existing in this version, whenever a +SPC-only block device (pendrive ?) is attached, this version fixes the +main issue for LP: 1833618, wrong ID_SERIAL for those devices. + +Udev rules from sg3-utils will, still, execute SCSI INQ 0X80 trying to use VPDs +from the kernel, and those will fail fast. Unfortunately, the subsequent SCSI +INQ 0x83 command, also trying to use VPDs from kernel, will take much longer +time (sometimes up to 1 minute) to fail when it sees there is no existing +vpd_pg83 file in sysfs and send an INQ to the USB block device, adding a delay +in the device attachment. This is not being addressed in this fix as this is +still present in upstream version. + +This last issue has to be addressed in a future sg3-utils-merge and +that is why is being documented here (when this patch will likely be +dropped). + +Signed-off-by: Rafael David Tinoco + +Author: Douglas Gilbert +Origin: upstream, https://github.com/hreinecke/sg3_utils/commit/988e967513f +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1833618 +Last-Update: 2019-10-09 +--- + scripts/55-scsi-sg3_id.rules | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/scripts/55-scsi-sg3_id.rules b/scripts/55-scsi-sg3_id.rules +index e914a5d..8c7356b 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}" +-- +2.20.1 + diff -Nru sg3-utils-1.42/debian/patches/new-location-for-major-and-minor.patch sg3-utils-1.42/debian/patches/new-location-for-major-and-minor.patch --- sg3-utils-1.42/debian/patches/new-location-for-major-and-minor.patch 1970-01-01 00:00:00.000000000 +0000 +++ sg3-utils-1.42/debian/patches/new-location-for-major-and-minor.patch 2019-10-09 06:13:54.000000000 +0000 @@ -0,0 +1,35 @@ +Description: new location for major() and minor() + +[Backport] + Only backported the header location change. + +Signed-off-by: Rafael David Tinoco + +Author: Rafael David Tinoco +Origin: backport, https://github.com/hreinecke/sg3_utils/commit/3e50c99af4a4 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/sg3-utils/+bug/1833618 +Last-Update: 2019-10-01 +--- + src/sg_map26.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/sg_map26.c b/src/sg_map26.c +index 1a1301a..92f6de9 100644 +--- a/src/sg_map26.c ++++ b/src/sg_map26.c +@@ -31,8 +31,11 @@ + #include + #include + #include +-#include + #include ++#include /* new location for major + minor */ ++#ifndef major ++#include ++#endif + #include + + #ifdef HAVE_CONFIG_H +-- +2.20.1 + diff -Nru sg3-utils-1.42/debian/patches/series sg3-utils-1.42/debian/patches/series --- sg3-utils-1.42/debian/patches/series 2016-03-22 16:45:23.000000000 +0000 +++ sg3-utils-1.42/debian/patches/series 2019-10-09 06:13:54.000000000 +0000 @@ -1 +1,3 @@ ship-rescan-script.sh +55-scsi-sg3_id.rules-ID_SERIAL-fix.patch +new-location-for-major-and-minor.patch