From: Brian Bunker <brian@purestorage.com>
To: linux-scsi@vger.kernel.org
Cc: "Martin K . Petersen" <mkp@kernel.org>,
"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
Hannes Reinecke <hare@kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
Krishna Kant <krishna.kant@purestorage.com>
Subject: [PATCH v2 3/4] scsi: scsi_dh_alua: Start a port group in the scanned access state
Date: Wed, 28 Oct 2026 16:08:06 -0700 [thread overview]
Message-ID: <20261028230807.61578-4-brian@purestorage.com> (raw)
In-Reply-To: <20261028230807.61578-1-brian@purestorage.com>
A new port group starts out active/optimized until the first RTPG of
the handler completes, so alua_prep_fn() lets I/O through to a path
that is actually unavailable. For a device whose driver is bound
straight away, the first I/O, typically the partition table read, then
reaches the target and fails with LOGICAL UNIT NOT ACCESSIBLE, TARGET
PORT IN UNAVAILABLE STATE, logging an I/O error.
The SCSI core now reads sdev->access_state when the device is scanned,
before the handler attaches. Start a new port group in that state. If
the core did not read one, sdev->access_state is zero, which is
active/optimized, so nothing changes for those devices.
Co-developed-by: Krishna Kant <krishna.kant@purestorage.com>
Signed-off-by: Krishna Kant <krishna.kant@purestorage.com>
Signed-off-by: Brian Bunker <brian@purestorage.com>
---
drivers/scsi/device_handler/scsi_dh_alua.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 06eb35cc9d7c..15471e7bf19a 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -208,7 +208,14 @@ static struct alua_port_group *alua_alloc_pg(struct scsi_device *sdev,
}
pg->group_id = group_id;
pg->tpgs = tpgs;
- pg->state = SCSI_ACCESS_STATE_OPTIMAL;
+ /*
+ * Start in the access state the SCSI core read when the device was
+ * scanned. That is active/optimized if it did not read one, as it
+ * was before. alua_prep_fn() then already fails I/O to a path that
+ * is unavailable before the first RTPG of the handler completes.
+ */
+ pg->state = FIELD_GET(SCSI_ACCESS_STATE_MASK, sdev->access_state);
+ pg->pref = FIELD_GET(SCSI_ACCESS_STATE_PREFERRED, sdev->access_state);
pg->valid_states = TPGS_SUPPORT_ALL;
if (optimize_stpg)
pg->flags |= ALUA_OPTIMIZE_STPG;
--
2.56.0
next prev parent reply other threads:[~2026-10-28 23:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 23:08 [PATCH v2 0/4] scsi: Bind sd to LUs in the ALUA unavailable state Brian Bunker
2026-10-28 23:08 ` [PATCH v2 1/4] scsi: core: Move REPORT TARGET PORT GROUPS into the SCSI core Brian Bunker
2026-10-28 23:08 ` [PATCH v2 2/4] scsi: core: Read the ALUA access state when a device is scanned Brian Bunker
2026-10-28 23:08 ` Brian Bunker [this message]
2026-10-28 23:19 ` [PATCH v2 3/4] scsi: scsi_dh_alua: Start a port group in the scanned access state sashiko-bot
2026-10-28 23:08 ` [PATCH v2 4/4] scsi: core: Match ULDs to logical units in the ALUA unavailable state Brian Bunker
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=20261028230807.61578-4-brian@purestorage.com \
--to=brian@purestorage.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bvanassche@acm.org \
--cc=hare@kernel.org \
--cc=krishna.kant@purestorage.com \
--cc=linux-scsi@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.