From: Brian Bunker <brian@purestorage.com>
To: Hannes Reinecke <hare@suse.de>,
Bart Van Assche <bvanassche@acm.org>,
linux-scsi@vger.kernel.org
Cc: "Martin K . Petersen" <mkp@kernel.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
James.Bottomley@HansenPartnership.com,
krishna.kant@purestorage.com
Subject: Re: [PATCH v8 0/5] scsi: Refresh INQUIRY data and reprobe on rescan
Date: Thu, 22 Oct 2026 11:04:48 -0700 [thread overview]
Message-ID: <20261022180448.35270-1-brian@purestorage.com> (raw)
In-Reply-To: <524b50e3-cdcf-4cf3-861f-a647a07ae6e8@suse.de>
On 10/22/26 1:56 PM, Hannes Reinecke wrote:
> But if you want to have this behaviour it would make sense to modify
> scsi_bus_match() to extend to pqual 01b, too; then 'sd' would stay
> bound to the scsi device even after rescan, and we wouldn't need
> to worry about driver detaching and multipathd becoming inoperational.
[...]
> But still it might be worthwhile exploring the idea of extending
> scsi_bus_match(), as that will solve any ambiguity with 'sd' attaching
> to the device.
I agree, and I'd much rather do that than the reprobe. It was my first
idea in "The PQ=1 saga" thread in 2023, but matching PQ = 1 on its own
isn't safe, and I think I now understand why Martin pushed back then.
PQ = 001b has two meanings. One is the ALUA unavailable state, which
SPC-4 5.15.2.4.5 a) requires. The other is a LUN that isn't mapped to
the initiator at all. SPC-4 6.6.1 says:
In response to an INQUIRY command received by an incorrect logical
unit, the SCSI target device shall return the INQUIRY data with the
peripheral qualifier set to the value defined in 6.6.2. The device
server shall terminate an INQUIRY command with CHECK CONDITION
status only if the device server is unable to return the requested
INQUIRY data.
So the INQUIRY succeeds, and 6.6.2 decides the qualifier. An array
can map a volume at any of its LUNs, so 011b ("The device server is
not capable of supporting a peripheral device on this logical unit")
would be wrong. 001b is the correct answer for a LUN that could hold a
volume but currently doesn't:
001b A peripheral device having the indicated peripheral device type
is not connected to this logical unit. However, the device
server is capable of supporting the indicated peripheral device
type on this logical unit.
An array that returns PQ = 1 for an unmapped LUN is therefore doing
exactly what the standard says. The trap is set elsewhere, by REPORT
LUNS. Some arrays, at least in the past, returned a full LUN list
(0 to 255) in REPORT LUNS and left it to the initiator to work out
which LUNs were really there. Linux then sends INQUIRY to every one of
them and, correctly, gets PQ = 1 back from all the unmapped ones. Binding sd at
PQ = 1 would turn each of those into a disk with nothing behind it: no
READ CAPACITY, no logical block size. I suspect that is the experience
behind Martin's "there are also storage arrays out there that rely on
PQ=1 to inhibit devices being claimed", and the IBM 2145 case in
948e922fc446 (PQ = 1, PDT 0 for a LUN that isn't mapped) looks like
the same thing.
Checking TPGS doesn't help, because the TPGS bits come from the same
INQUIRY response. The array fills in the standard INQUIRY data for an
unmapped LUN the same way it does for a mapped one.
A command other than INQUIRY does tell the two apart. A LUN that isn't
mapped rejects REPORT TARGET PORT GROUPS with LOGICAL UNIT NOT
SUPPORTED, while a LU in the unavailable state must accept it
(5.15.2.4.5 c)) and reports its target port group as unavailable.
The ALUA handler is already in the right place to send it.
scsi_sysfs_add_sdev() calls scsi_dh_add_device() before device_add(),
so scsi_dh_alua has attached before scsi_bus_match() runs. The only
thing missing is the RTPG result: alua_check_vpd() queues the first
RTPG with alua_rtpg_queue(), so it normally completes after the device
has been matched.
So my proposal is:
- In scsi_dh_alua, for a device that reported PQ = 1, send the first
RTPG synchronously at attach time and set sdev->access_state from
that device's own response. An unmapped LUN fails the RTPG and
stays as it is today. The queued RTPG and the shared port group
handling stay as they are, so an unmapped LUN can't pick up
another LU's state from the port group.
- In scsi_bus_match(), match PQ = 0 as today, and also PQ = 1 when
access_state says unavailable.
sd then binds to an unavailable path whether the host was running when
the path became unavailable or scanned while it was. The path stays in
the multipath map as a failed path, multipathd keeps polling it, and
the existing UNIT ATTENTION handling brings it back, as you described.
This relies on scsi_dh_alua being attached at scan time (built in, or
loaded before the scan), which I think is how it should work anyway.
It would replace the v8 reprobe completely: no INQUIRY refresh, no
reprobe, and no change to the scan path.
Would you take a synchronous first RTPG in alua_check_vpd() for PQ = 1
devices? If you'd rather keep the handler as it is, the alternative is
for the SCSI core to send a TEST UNIT READY to PQ = 1 LUNs during the
scan and look for LOGICAL UNIT NOT ACCESSIBLE, TARGET PORT IN
UNAVAILABLE STATE, but I think the handler is the better place for it.
Thanks,
Brian
next prev parent reply other threads:[~2026-10-22 18:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 22:13 [PATCH v8 0/5] scsi: Refresh INQUIRY data and reprobe on rescan Brian Bunker
2026-10-19 22:14 ` [PATCH v8 1/5] scsi: core: Protect INQUIRY sysfs attributes with mutex Brian Bunker
2026-10-19 22:14 ` [PATCH v8 2/5] scsi: core: Add scsi_update_inquiry_data() for updating INQUIRY data Brian Bunker
2026-10-19 22:14 ` [PATCH v8 3/5] scsi: core: Refactor scsi_add_lun() to use scsi_update_inquiry_data() Brian Bunker
2026-10-19 22:14 ` [PATCH v8 4/5] scsi: core: Add device reprobe support to scsi_rescan_device() Brian Bunker
2026-10-19 22:31 ` sashiko-bot
2026-10-19 22:14 ` [PATCH v8 5/5] scsi: core: Handle reprobe for existing devices during SCSI scan Brian Bunker
2026-10-19 22:32 ` sashiko-bot
2026-10-19 22:41 ` [PATCH v8 0/5] scsi: Refresh INQUIRY data and reprobe on rescan Bart Van Assche
2026-10-20 17:17 ` Brian Bunker
2026-10-20 22:09 ` Bart Van Assche
2026-10-21 17:04 ` Brian Bunker
2026-10-21 10:45 ` Hannes Reinecke
2026-10-21 13:21 ` Bart Van Assche
2026-10-21 18:50 ` Brian Bunker
2026-10-22 11:56 ` Hannes Reinecke
2026-10-22 18:04 ` Brian Bunker [this message]
2026-10-23 6:59 ` Hannes Reinecke
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=20261022180448.35270-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 \
--cc=mkp@kernel.org \
/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