From: Brian Bunker <brian@purestorage.com>
To: linux-scsi@vger.kernel.org
Cc: James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, hare@suse.de, bvanassche@acm.org,
krishna.kant@purestorage.com
Subject: [PATCH v5 0/5] scsi: Refresh INQUIRY data and reprobe on rescan
Date: Thu, 18 Jun 2026 16:34:59 -0700 [thread overview]
Message-ID: <20260618233508.97960-1-brian@purestorage.com> (raw)
This series teaches the SCSI rescan path to refetch standard INQUIRY data
and reprobe the device when the peripheral qualifier or device type has
changed. The motivating case is an ALUA target that transitions through
the "unavailable" state and afterwards reports a different peripheral
qualifier; today the kernel keeps the stale INQUIRY data and the device's
sysfs attributes diverge from what the target reports.
1/5 serializes the INQUIRY-derived sysfs attributes under
sdev->inquiry_mutex so a concurrent reprobe cannot tear the read.
2/5 adds scsi_update_inquiry_data() as the single point that copies a
freshly-fetched INQUIRY buffer into sdev and updates derived fields.
Returns SCSI_INQ_REPROBE_NEEDED only when peripheral qualifier or
device type changes, as these are the only fields that determine
driver binding.
3/5 refactors scsi_add_lun() to use scsi_update_inquiry_data(), sharing
one implementation between initial-probe and reprobe paths.
4/5 teaches scsi_rescan_device() to refetch INQUIRY and reprobe the
device when scsi_update_inquiry_data() reports a change.
5/5 wires the same path into scsi_probe_and_add_lun() so existing
devices encountered during a SCAN_LUNS pass get refreshed.
Changes since v4:
- 1/5: No code changes. Added Reviewed-by: Hannes Reinecke.
- 2/5: No code changes. The per-field reprobe detection (old_type,
old_periph_qual) is retained: device_reprobe() should only be
triggered by changes to type or peripheral qualifier, as these are
the only fields that affect driver binding. All other fields are
refreshed unconditionally regardless of the reprobe decision.
Added Reviewed-by: Hannes Reinecke.
- 3/5: Added a comment documenting that scsi_probe_lun() already
enforces sdev->inquiry_len >= 36, so no max_t() guard is needed
at the scsi_update_inquiry_data() call site.
- 4/5: Rework of the reprobe path in scsi_rescan_device():
- Added max_t(size_t, sdev->inquiry_len, 36) at the call site.
- Hold get_device()/put_device() across the device_unlock() /
device_reprobe() / device_lock() sequence so sdev cannot be
freed while the lock is dropped.
- After dropping device_lock for device_reprobe(), re-check
sdev_state for SDEV_CANCEL/SDEV_DEL on re-acquire; drop the
device reference and return -ENODEV if so.
- Mark device offline on device_reprobe() failure; failure indicates
either a bad target (-EINVAL) or OOM (-ENOMEM), both of which leave
the device unusable.
- 5/5: No code changes from v4.
v4 cover-letter Message-ID: <20260530002019.47109-1-brian@purestorage.com>
v3 cover-letter Message-ID: <20260429224939.77082-1-brian@purestorage.com>
v2 cover-letter Message-ID: <20260429012733.40855-1-brian@purestorage.com>
v1 cover-letter Message-ID: <20260424215324.99045-1-brian@purestorage.com>
Brian Bunker (5):
scsi: core: Protect INQUIRY sysfs attributes with mutex
scsi: core: Add scsi_update_inquiry_data() for updating INQUIRY data
scsi: core: Refactor scsi_add_lun() to use scsi_update_inquiry_data()
scsi: core: Add device reprobe support to scsi_rescan_device()
scsi: core: Handle reprobe for existing devices during SCSI scan
drivers/scsi/scsi.c | 178 +++++++++++++++++++
drivers/scsi/scsi_scan.c | 353 +++++++++++++++++++++++++------------
drivers/scsi/scsi_sysfs.c | 28 ++-
include/scsi/scsi_device.h | 13 ++
4 files changed, 447 insertions(+), 125 deletions(-)
--
2.54.0
next reply other threads:[~2026-06-18 23:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 23:34 Brian Bunker [this message]
2026-06-18 23:35 ` [PATCH v5 1/5] scsi: core: Protect INQUIRY sysfs attributes with mutex Brian Bunker
2026-06-18 23:35 ` [PATCH v5 2/5] scsi: core: Add scsi_update_inquiry_data() for updating INQUIRY data Brian Bunker
2026-06-18 23:35 ` [PATCH v5 3/5] scsi: core: Refactor scsi_add_lun() to use scsi_update_inquiry_data() Brian Bunker
2026-06-19 6:00 ` Hannes Reinecke
2026-06-18 23:35 ` [PATCH v5 4/5] scsi: core: Add device reprobe support to scsi_rescan_device() Brian Bunker
2026-06-19 6:01 ` Hannes Reinecke
2026-06-18 23:35 ` [PATCH v5 5/5] scsi: core: Handle reprobe for existing devices during SCSI scan Brian Bunker
2026-06-19 6:01 ` Hannes Reinecke
2026-07-12 21:31 ` [PATCH v5 0/5] scsi: Refresh INQUIRY data and reprobe on rescan Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260618233508.97960-1-brian@purestorage.com \
--to=brian@purestorage.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=krishna.kant@purestorage.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox