From: John Garry <john.g.garry@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 08/17] scsi-multipath: provide callbacks for path state
Date: Mon, 6 Jul 2026 16:38:40 +0100 [thread overview]
Message-ID: <6a760386-9e13-4331-bfe8-d30e356cbab3@oracle.com> (raw)
In-Reply-To: <20260703114918.1CC661F000E9@smtp.kernel.org>
On 03/07/2026 12:49, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] `scsi_mpath_is_disabled` and `scsi_mpath_is_optimized` fail to mask out the `SCSI_ACCESS_STATE_PREFERRED` flag from `sdev->access_state`.
> - [High] `scsi_mpath_available_path()` incorrectly treats `SDEV_CREATED_BLOCK` as an available path.
> --
>
> commit 71967b8cc1b7e6dc50c814782c317913564b9ee9
> Author: John Garry <john.g.garry@oracle.com>
>
> scsi-multipath: provide callbacks for path state
>
> This patch provides callbacks for path states in SCSI multipath, including
> scsi_mpath_is_disabled, scsi_mpath_is_optimized, and
> scsi_mpath_available_path. These rely on the SCSI device's sdev_state and
> access_state to determine path availability.
>
>> diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c
>> index f22e3677cf2ad..d8ea9ffe8942c 100644
>> --- a/drivers/scsi/scsi_multipath.c
>> +++ b/drivers/scsi/scsi_multipath.c
>> @@ -301,7 +301,53 @@ static struct bio *scsi_mpath_clone_bio(struct bio *bio)
>
> [ ... ]
>
>> +static bool scsi_mpath_is_disabled(struct mpath_device *mpath_device)
>> +{
>> + struct scsi_mpath_device *scsi_mpath_dev =
>> + to_scsi_mpath_device(mpath_device);
>> + struct scsi_device *sdev = scsi_mpath_dev->sdev;
>> + unsigned char access_state = READ_ONCE(sdev->access_state);
>> +
>> + if (sdev->sdev_state != SDEV_RUNNING)
>> + return true;
>> +
>> + if (access_state == SCSI_ACCESS_STATE_OPTIMAL ||
>> + access_state == SCSI_ACCESS_STATE_ACTIVE)
>
> [Severity: High]
> Does this comparison correctly handle ALUA preferred paths?
>
> If a device handler sets sdev->access_state to include the preferred bit
> (SCSI_ACCESS_STATE_OPTIMAL | SCSI_ACCESS_STATE_PREFERRED), this raw byte
> comparison will fail. This would cause the multipath layer to incorrectly
> classify valid, optimal preferred paths as disabled, potentially discarding
> them from I/O consideration.
>
> Should this mask the access_state with SCSI_ACCESS_STATE_MASK before
> comparing?
will fix
>
>> + return false;
>> +
>> + return true;
>> +}
>> +
>> +static bool scsi_mpath_is_optimized(struct mpath_device *mpath_device)
>> +{
>> + struct scsi_mpath_device *scsi_mpath_dev =
>> + to_scsi_mpath_device(mpath_device);
>> + struct scsi_device *sdev = scsi_mpath_dev->sdev;
>> +
>> + if (sdev->sdev_state != SDEV_RUNNING)
>> + return false;
>> +
>> + return READ_ONCE(sdev->access_state) == SCSI_ACCESS_STATE_OPTIMAL;
>
> [Severity: High]
> Similar to the check in scsi_mpath_is_disabled(), will this strict equality
> check misclassify optimal paths that also have the
> SCSI_ACCESS_STATE_PREFERRED flag set?
will fix
>
>> +}
>> +
>> +static bool scsi_mpath_available_path(struct mpath_device *mpath_device)
>> +{
>> + struct scsi_mpath_device *scsi_mpath_dev =
>> + to_scsi_mpath_device(mpath_device);
>> + struct scsi_device *sdev = scsi_mpath_dev->sdev;
>> + enum scsi_device_state sdev_state = sdev->sdev_state;
>> +
>> + if (sdev_state == SDEV_RUNNING || sdev_state == SDEV_QUIESCE ||
>> + sdev_state == SDEV_BLOCK || sdev_state == SDEV_CREATED_BLOCK)
>
> [Severity: High]
> Is it intended to route user I/O to a device in the SDEV_CREATED_BLOCK state?
>
> Devices in SDEV_CREATED and SDEV_CREATED_BLOCK are newly created, not fully
> initialized, and generally only accept internal commands. If a newly created
> device is temporarily blocked, this function returns true and routes user I/O
> to it, which could lead to I/O rejection or indefinite blocking.
It does not specifically route IO to it, but allows IO to be requeued
for the head to be issued later
>
> Furthermore, when the device unblocks and returns to SDEV_CREATED, this
> function would suddenly return false. Should SDEV_CREATED_BLOCK be excluded
> from the available paths list?
probably
>
>> + return true;
>> +
>> + return false;
>> +}
>
next prev parent reply other threads:[~2026-07-06 15:38 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:33 [PATCH v3 00/17] Native SCSI multipath support John Garry
2026-07-03 10:33 ` [PATCH v3 01/17] scsi-multipath: introduce basic SCSI device support John Garry
2026-07-03 10:53 ` sashiko-bot
2026-07-06 14:39 ` John Garry
2026-07-03 10:33 ` [PATCH v3 02/17] scsi-multipath: introduce scsi_device head structure John Garry
2026-07-03 10:49 ` sashiko-bot
2026-07-06 14:45 ` John Garry
2026-07-03 10:33 ` [PATCH v3 03/17] scsi-multipath: provide sysfs link from to scsi_device John Garry
2026-07-03 11:04 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 04/17] scsi-multipath: support iopolicy John Garry
2026-07-03 11:10 ` sashiko-bot
2026-07-06 14:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 05/17] scsi-multipath: clone each bio John Garry
2026-07-03 11:26 ` sashiko-bot
2026-07-06 14:53 ` John Garry
2026-07-03 10:33 ` [PATCH v3 06/17] scsi-multipath: clear path when device is blocked John Garry
2026-07-03 11:32 ` sashiko-bot
2026-07-06 15:04 ` John Garry
2026-07-03 10:33 ` [PATCH v3 07/17] scsi-multipath: failover handling John Garry
2026-07-03 11:40 ` sashiko-bot
2026-07-06 15:32 ` John Garry
2026-07-03 10:33 ` [PATCH v3 08/17] scsi-multipath: provide callbacks for path state John Garry
2026-07-03 11:49 ` sashiko-bot
2026-07-06 15:38 ` John Garry [this message]
2026-07-03 10:33 ` [PATCH v3 09/17] scsi-multipath: add scsi_mpath_{start,end}_request() John Garry
2026-07-03 11:53 ` sashiko-bot
2026-07-06 15:44 ` John Garry
2026-07-03 10:33 ` [PATCH v3 10/17] scsi-multipath: block PR commands John Garry
2026-07-03 12:03 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 11/17] scsi-multipath: add delayed disk removal support John Garry
2026-07-03 12:08 ` sashiko-bot
2026-07-06 15:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 12/17] scsi: sd: add multipath disk class John Garry
2026-07-03 10:33 ` [PATCH v3 13/17] scsi: sd: support multipath disk John Garry
2026-07-03 12:24 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 14/17] scsi: sd: add multipath disk attr groups John Garry
2026-07-03 12:25 ` sashiko-bot
2026-07-03 10:34 ` [PATCH v3 15/17] scsi: sd: add mpath_dev file John Garry
2026-07-03 12:43 ` sashiko-bot
2026-07-06 15:56 ` John Garry
2026-07-03 10:34 ` [PATCH v3 16/17] scsi: sd: add mpath_numa_nodes dev attribute John Garry
2026-07-03 12:44 ` sashiko-bot
2026-07-06 15:57 ` John Garry
2026-07-03 10:34 ` [PATCH v3 17/17] scsi: sd: add mpath_queue_depth " John Garry
2026-07-03 12:57 ` sashiko-bot
2026-07-06 15:59 ` John Garry
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=6a760386-9e13-4331-bfe8-d30e356cbab3@oracle.com \
--to=john.g.garry@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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