From: sashiko-bot@kernel.org
To: "John Garry" <john.g.garry@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v4 03/28] libmultipath: Add path selection support
Date: Thu, 23 Jul 2026 09:55:11 +0000 [thread overview]
Message-ID: <20260723095512.6CF7F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723093627.2327456-4-john.g.garry@oracle.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The round-robin path selector can enter an infinite loop (SRCU lockup) if the currently selected path is removed concurrently.
- [Medium] Calling `list_is_singular()` on an SRCU-protected list introduces data races and state inconsistencies.
- [Low] Missing `WRITE_ONCE()` when updating `iopolicy` causes a data race with lockless readers.
--
--- Patch [3]: [PATCH v4 03/28] libmultipath: Add path selection support ---
commit 84fab111a99eb088e0b8abed39b8163220a9318d
Author: John Garry <john.g.garry@oracle.com>
libmultipath: Add path selection support
Add code for path selection. NVMe ANA is abstracted into enum
mpath_access_state so that SCSI ALUA can be used. Path selection modes
round-robin, NUMA, and queue-depth are added.
> diff --git a/lib/multipath.c b/lib/multipath.c
> index 916d01a285284..20bb8cb0ea956 100644
> --- a/lib/multipath.c
> +++ b/lib/multipath.c
[ ... ]
> +int mpath_set_iopolicy(const char *str, enum mpath_iopolicy_e *iopolicy)
> +{
> + int policy;
> +
> + if (!str)
> + return -EINVAL;
> + policy = mpath_iopolicy_parse(str);
> + if (policy < 0)
> + return policy;
> + *iopolicy = policy;
[Severity: Low]
Does this code need a WRITE_ONCE() for the assignment?
mpath_read_iopolicy() safely accesses this locklessly via READ_ONCE(), but
this plain store could cause a data race violating LKMM guidelines and
triggering KCSAN warnings.
> +
> + return 0;
> +}
[ ... ]
> +static struct mpath_device *mpath_round_robin_path(
> + struct mpath_head *mpath_head)
> +{
> + struct mpath_device *mpath_device, *found = NULL;
> + int node = numa_node_id();
> + enum mpath_access_state access_state_old;
> + struct mpath_device *old =
> + srcu_dereference(mpath_head->current_path[node],
> + &mpath_head->srcu);
> +
> + if (unlikely(!old))
> + return __mpath_find_path(mpath_head, node);
> +
> + if (list_is_singular(&mpath_head->dev_list)) {
> + if (mpath_path_is_disabled(mpath_head, old))
> + return NULL;
> + return old;
> + }
[Severity: Medium]
Is it safe to use list_is_singular() on an SRCU-protected list here?
list_is_singular() reads head->prev, which is a writer-only pointer in
RCU-protected lists, introducing a data race.
Additionally, if old was just concurrently unlinked leaving exactly one other
active device in the list, list_is_singular() evaluates to true. Could this
cause the function to incorrectly return the unlinked device instead of the
actual remaining device?
> +
> + for (mpath_device = mpath_next_dev(mpath_head, old);
> + mpath_device && mpath_device != old;
> + mpath_device = mpath_next_dev(mpath_head, mpath_device)) {
[Severity: High]
Can this loop become infinite if the currently selected path is removed
concurrently?
If a concurrent thread unlinks old from the list, mpath_next_dev() will never
reach mpath_device == old to break the loop. Since old is unlinked, traversal
might wrap around the circular list infinitely, causing a hard lockup within
the SRCU read-side critical section.
Unlike the NVMe equivalent nvme_round_robin_path(), which avoids this by
breaking early if it cycles back to a fallback node, this patch omits that
loop termination condition. If no other path is MPATH_STATE_OPTIMIZED, could
this run forever?
> +
> + if (mpath_path_is_disabled(mpath_head, mpath_device))
> + continue;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723093627.2327456-1-john.g.garry@oracle.com?part=3
next prev parent reply other threads:[~2026-07-23 9:55 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 9:35 [PATCH v4 00/28] Native SCSI Multipath support John Garry
2026-07-23 9:35 ` [PATCH v4 01/28] libmultipath: Add initial framework John Garry
2026-07-23 9:50 ` sashiko-bot
2026-07-23 10:19 ` John Garry
2026-07-23 9:36 ` [PATCH v4 02/28] libmultipath: Add basic gendisk support John Garry
2026-07-23 9:57 ` sashiko-bot
2026-07-23 10:34 ` John Garry
2026-07-23 9:36 ` [PATCH v4 03/28] libmultipath: Add path selection support John Garry
2026-07-23 9:55 ` sashiko-bot [this message]
2026-07-23 10:28 ` John Garry
2026-07-23 9:36 ` [PATCH v4 04/28] libmultipath: Add bio handling John Garry
2026-07-23 9:36 ` [PATCH v4 05/28] libmultipath: Add support for mpath_device management John Garry
2026-07-23 9:58 ` sashiko-bot
2026-07-23 10:36 ` John Garry
2026-07-23 9:36 ` [PATCH v4 06/28] libmultipath: Add delayed removal support John Garry
2026-07-23 9:57 ` sashiko-bot
2026-07-23 10:33 ` John Garry
2026-07-23 9:36 ` [PATCH v4 07/28] libmultipath: Add sysfs helpers John Garry
2026-07-23 10:05 ` sashiko-bot
2026-07-23 10:37 ` John Garry
2026-07-23 9:36 ` [PATCH v4 08/28] libmultipath: Add mpath_bdev_report_zones() John Garry
2026-07-23 10:15 ` sashiko-bot
2026-07-23 10:39 ` John Garry
2026-07-23 9:36 ` [PATCH v4 09/28] libmultipath: Add support for block device IOCTL John Garry
2026-07-23 10:09 ` sashiko-bot
2026-07-23 10:38 ` John Garry
2026-07-23 9:36 ` [PATCH v4 10/28] libmultipath: Add mpath_bdev_getgeo() John Garry
2026-07-23 9:36 ` [PATCH v4 11/28] libmultipath: Add mpath_bdev_get_unique_id() John Garry
2026-07-23 9:36 ` [PATCH v4 12/28] scsi-multipath: introduce basic SCSI device support John Garry
2026-07-23 10:14 ` sashiko-bot
2026-07-23 9:36 ` [PATCH v4 13/28] scsi-multipath: introduce scsi_device head structure John Garry
2026-07-23 10:16 ` sashiko-bot
2026-07-23 10:47 ` John Garry
2026-07-23 9:36 ` [PATCH v4 14/28] scsi-multipath: provide sysfs link from to scsi_device John Garry
2026-07-23 9:36 ` [PATCH v4 15/28] scsi-multipath: support iopolicy John Garry
2026-07-23 10:20 ` sashiko-bot
2026-07-23 10:51 ` John Garry
2026-07-23 9:36 ` [PATCH v4 16/28] scsi-multipath: clone each bio John Garry
2026-07-23 10:27 ` sashiko-bot
2026-07-23 10:55 ` John Garry
2026-07-23 9:36 ` [PATCH v4 17/28] scsi-multipath: clear path when device is blocked John Garry
2026-07-23 10:33 ` sashiko-bot
2026-07-23 11:01 ` John Garry
2026-07-23 9:36 ` [PATCH v4 18/28] scsi-multipath: revalidate paths upon device unblock John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:15 ` John Garry
2026-07-23 9:36 ` [PATCH v4 19/28] scsi-multipath: failover handling John Garry
2026-07-23 10:36 ` sashiko-bot
2026-07-23 11:03 ` John Garry
2026-07-23 9:36 ` [PATCH v4 20/28] scsi-multipath: provide callbacks for path state John Garry
2026-07-23 10:36 ` sashiko-bot
2026-07-23 11:05 ` John Garry
2026-07-23 9:36 ` [PATCH v4 21/28] scsi-multipath: add scsi_mpath_{start,end}_request() John Garry
2026-07-23 10:32 ` sashiko-bot
2026-07-23 10:57 ` John Garry
2026-07-23 9:36 ` [PATCH v4 22/28] scsi-multipath: add delayed disk removal support John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:21 ` John Garry
2026-07-23 9:36 ` [PATCH v4 23/28] scsi: sd: add multipath disk class John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:21 ` John Garry
2026-07-23 9:36 ` [PATCH v4 24/28] scsi: sd: add multipath disk attr groups John Garry
2026-07-23 10:47 ` sashiko-bot
2026-07-23 11:22 ` John Garry
2026-07-23 9:36 ` [PATCH v4 25/28] scsi: sd: support multipath disk John Garry
2026-07-23 10:47 ` sashiko-bot
2026-07-23 11:27 ` John Garry
2026-07-23 16:52 ` John Garry
2026-07-23 9:36 ` [PATCH v4 26/28] scsi: sd: add mpath_dev file John Garry
2026-07-23 11:07 ` sashiko-bot
2026-07-23 11:30 ` John Garry
2026-07-23 9:36 ` [PATCH v4 27/28] scsi: sd: add mpath_numa_nodes dev attribute John Garry
2026-07-23 10:52 ` sashiko-bot
2026-07-23 11:30 ` John Garry
2026-07-23 9:36 ` [PATCH v4 28/28] scsi: sd: add mpath_queue_depth " 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=20260723095512.6CF7F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=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