From: Maurizio Lombardi <mlombard@redhat.com>
To: kbusch@kernel.org
Cc: hch@lst.de, hare@suse.de, chaitanyak@nvidia.com,
bvanassche@acm.org, linux-scsi@vger.kernel.org,
linux-nvme@lists.infradead.org,
James.Bottomley@HansenPartnership.com, mlombard@arkamax.eu,
jmeneghi@redhat.com, emilne@redhat.com, bgurney@redhat.com
Subject: [PATCH V3 0/3] Ensure ordered namespace registration during async scan
Date: Wed, 25 Feb 2026 17:12:00 +0100 [thread overview]
Message-ID: <20260225161203.76168-1-mlombard@redhat.com> (raw)
The NVMe fully asynchronous namespace scanning introduced in
commit 4e893ca81170 ("nvme-core: scan namespaces asynchronously")
significantly improved discovery times. However, it also introduced
non-deterministic ordering for namespace registration.
While kernel device names (/dev/nvmeXnY) are not guaranteed to be stable
across reboots, this unpredictable ordering has caused considerable user
confusion and has been perceived as a regression, leading to multiple bug
reports.
This series introduces a solution to enforce strict sequential
registration based on NSID order, entirely preserving the performance
benefits of the asynchronous scan approach.
Instead of adding an NVMe-specific hack, this series abstracts the
serialization mechanism currently open-coded in the SCSI subsystem
(drivers/scsi/scsi_scan.c) into a generic library helper called the
completion chain (compl_chain).
By enforcing a strict First-In, First-Out (FIFO) completion order for
asynchronous tasks, we can ensure that namespaces are allocated and
registered sequentially without blocking the underlying parallel discovery
processes.
PATCH 3 Refactors the existing SCSI asynchronous scanning implementation
to use the new compl_chain helper, stripping out the custom, open-coded task
list and reducing code duplication.
Original code:
$ nvme list
Node Generic Namespace
--------------------- --------------------- ----------
/dev/nvme0n1 /dev/ng0n1 0x2
/dev/nvme0n2 /dev/ng0n2 0x1
/dev/nvme0n3 /dev/ng0n3 0x5
/dev/nvme0n4 /dev/ng0n4 0x3
/dev/nvme0n5 /dev/ng0n5 0x4
[...]
/dev/nvme0n10 /dev/ng0n10 0xa
/dev/nvme0n11 /dev/ng0n11 0x8
/dev/nvme0n12 /dev/ng0n12 0x12
/dev/nvme0n13 /dev/ng0n13 0x17
/dev/nvme0n14 /dev/ng0n14 0xc
/dev/nvme0n15 /dev/ng0n15 0x11
/dev/nvme0n16 /dev/ng0n16 0x14
/dev/nvme0n17 /dev/ng0n17 0x13
/dev/nvme0n18 /dev/ng0n18 0xe
/dev/nvme0n19 /dev/ng0n19 0xf
With this patch:
$ nvme list
Node Generic Namespace
--------------------- --------------------- ----------
/dev/nvme0n1 /dev/ng0n1 0x1
/dev/nvme0n2 /dev/ng0n2 0x2
/dev/nvme0n3 /dev/ng0n3 0x3
/dev/nvme0n4 /dev/ng0n4 0x4
/dev/nvme0n5 /dev/ng0n5 0x5
/dev/nvme0n6 /dev/ng0n6 0x6
[...]
/dev/nvme0n10 /dev/ng0n10 0xa
/dev/nvme0n11 /dev/ng0n11 0xb
/dev/nvme0n12 /dev/ng0n12 0xc
/dev/nvme0n13 /dev/ng0n13 0xd
/dev/nvme0n14 /dev/ng0n14 0xe
/dev/nvme0n15 /dev/ng0n15 0xf
/dev/nvme0n16 /dev/ng0n16 0x10
/dev/nvme0n17 /dev/ng0n17 0x11
/dev/nvme0n18 /dev/ng0n18 0x12
/dev/nvme0n19 /dev/ng0n19 0x13
V3: fixed some comments
PATCH 3: declare scanning_hosts as static
remove "extern" keyword from scsi_complete_async_scans()
prototype declaration
V2: create the compl_chain helper that both SCSI and NVMe can share
Maurizio Lombardi (3):
lib: Introduce completion chain helper
nvme-core: register namespaces in order during async scan
scsi: Convert async scanning to use the completion chain helper
drivers/nvme/host/core.c | 94 +++++++++++++++++-----------
drivers/nvme/host/nvme.h | 2 +
drivers/scsi/scsi_priv.h | 2 +-
drivers/scsi/scsi_scan.c | 68 +++------------------
include/linux/compl_chain.h | 35 +++++++++++
lib/Makefile | 2 +-
lib/compl_chain.c | 118 ++++++++++++++++++++++++++++++++++++
7 files changed, 225 insertions(+), 96 deletions(-)
create mode 100644 include/linux/compl_chain.h
create mode 100644 lib/compl_chain.c
--
2.53.0
next reply other threads:[~2026-02-25 16:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 16:12 Maurizio Lombardi [this message]
2026-02-25 16:12 ` [PATCH V3 1/3] lib: Introduce completion chain helper Maurizio Lombardi
2026-02-25 16:12 ` [PATCH V3 2/3] nvme-core: register namespaces in order during async scan Maurizio Lombardi
2026-02-25 21:37 ` kernel test robot
2026-02-25 16:12 ` [PATCH V3 3/3] scsi: Convert async scanning to use the completion chain helper Maurizio Lombardi
2026-02-25 21:41 ` [PATCH V3 0/3] Ensure ordered namespace registration during async scan Keith Busch
2026-02-26 8:07 ` Maurizio Lombardi
2026-02-26 15:09 ` Keith Busch
2026-02-26 16:35 ` John Meneghini
2026-02-26 18:15 ` Keith Busch
2026-03-02 7:16 ` Hannes Reinecke
2026-03-02 17:12 ` Keith Busch
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=20260225161203.76168-1-mlombard@redhat.com \
--to=mlombard@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bgurney@redhat.com \
--cc=bvanassche@acm.org \
--cc=chaitanyak@nvidia.com \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jmeneghi@redhat.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mlombard@arkamax.eu \
/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