Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v5 0/5] scsi: Refresh INQUIRY data and reprobe on rescan
@ 2026-06-18 23:34 Brian Bunker
  2026-06-18 23:35 ` [PATCH v5 1/5] scsi: core: Protect INQUIRY sysfs attributes with mutex Brian Bunker
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Brian Bunker @ 2026-06-18 23:34 UTC (permalink / raw)
  To: linux-scsi
  Cc: James.Bottomley, martin.petersen, hare, bvanassche, krishna.kant

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-07-12 21:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 23:34 [PATCH v5 0/5] scsi: Refresh INQUIRY data and reprobe on rescan Brian Bunker
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox