[PATCH RFC 0/1] Ensure ordered namespace registration during async scan

Maurizio Lombardi mlombard at redhat.com
Mon Aug 4 04:43:54 PDT 2025


Hello,

The 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 I am perfectly aware that kernel device names
like /dev/nvmeXnY are not guaranteed to be stable across reboots,
the unpredictable ordering has caused user confusion and
has been perceived as a regression. This has led to bug reports from customers,
and as a result, the asynchronous scanning feature was reverted in RHEL.

I was thinking about a solution to enforce sequential registration while
preserving the performance benefits of the asynchronous scan approach.

This one uses a dependency chain built from a linked list of
asynchronous tasks.
Each task waits for the completion of the previous one before it proceeds to
allocate its namespace, thus guaranteeing that namespaces
are registered sequentially, following the NSID list order, exactly as it
worked before commit 4e893ca81170.

This method is inspired by a very similar mechanism used in the SCSI
subsystem for asynchronous scanning (see drivers/scsi/scsi_scan.c).

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

Maurizio Lombardi (1):
  nvme-core: register namespaces in order during async scan

 drivers/nvme/host/core.c | 145 ++++++++++++++++++++++++++++-----------
 drivers/nvme/host/nvme.h |   2 +
 2 files changed, 108 insertions(+), 39 deletions(-)

-- 
2.47.3




More information about the Linux-nvme mailing list