From: Wen Xiong <wenxiong@linux.ibm.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, kbusch@kernel.org,
gjoyce@linux.ibm.com, wenxiong@us.ibm.com
Subject: Re: [PATCH V2] nvme: Add module reference counting for multipath devices
Date: Mon, 24 Aug 2026 15:23:10 -0500 [thread overview]
Message-ID: <af79f498b1287a3304db97477452537f@linux.ibm.com> (raw)
In-Reply-To: <d58d0c4f-0789-4c99-94bc-e2e2121e7b7a@grimberg.me>
On 2026-08-22 19:46, Sagi Grimberg wrote:
> OK, I now read the original report regarding nvme root device. please
> disregard.
Hi Sagi,
Thanks for taking the time to review this!
If multipath NVMe is the root device and there is no single NVMe device
in the system, the tester can still rmmod nvme because the NVMe module's
reference count is 0 (PCIe).
For example,
System has 2 multipath nvme devices(nvme0 has 1 NS and nvme1 has 2 NS).
# nvme list
Node Generic SN Model
Namespace Usage
Format FW Rev
--------------------- --------------------- --------------------
---------------------------------------- ----------
-------------------------- ---------------- --------
/dev/nvme0n1 /dev/ng0n1 S6RUNE0R900042 1.6TB
NVMe Gen4 U.2 SSD III 0x1 400.08 GB / 400.08 GB
4 KiB + 0 B REV.SN66
/dev/nvme1n1 /dev/ng1n1 S6KZNE0RA00056 800GB
NVMe Gen4 U.2 SSD 0x1 400.08 GB / 400.08 GB
4 KiB + 0 B REV.SN4B
/dev/nvme1n2 /dev/ng1n2 S6KZNE0RA00056 800GB
NVMe Gen4 U.2 SSD
Without patch, reference count of nvme module is 0, "rmmod nvme" causes
system crashing.
#lsmod|grep nvme
nvme_tcp 262144 0
nvme 262144 0
nvme_fabrics 262144 1 nvme_tcp
nvme_core 458752 7 nvme_tcp,nvme,nvme_fabrics
nvme_keyring 262144 3 nvme_tcp,nvme_core,nvme_fabrics
nvme_auth 262144 1 nvme_core
static int nvme_ns_open(struct nvme_ns *ns)
{
/* should never be called due to GENHD_FL_HIDDEN */
if (WARN_ON_ONCE(nvme_ns_head_multipath(ns->head))) --------->
skip multipath devs
goto fail;
if (!nvme_get_ns(ns))
goto fail;
if (!try_module_get(ns->ctrl->ops->module))
goto fail_put_ns;
}
#rmmod nvme
[ 434.859171] block nvme2n1: no available path - failing I/O
[ 434.859204] XFS (nvme2n1p2): log I/O error -5
[ 434.859211] XFS (nvme2n1p2): Filesystem has been shut down due to log
error (0x2).
[ 434.859215] XFS (nvme2n1p2): Please unmount the filesystem and
rectify the problem(s).
[root@ltcrain119-lp4 nvme_upstream]# [ 439.349490] XFS (dm-0): metadata
I/O error in "xfs_imap_to_bp+0x74/0x108 [xfs]" at daddr 0x73d4ca0 len 32
error 5
[ 439.349651] XFS (dm-0): metadata I/O error in
"xfs_imap_to_bp+0x74/0x108 [xfs]" at daddr 0x73d4ca0 len 32 error 5
[ 439.353244] coredump: 26799(fwupd):
|/usr/lib/systemd/systemd-coredump pipe failed
[ 457.438961] XFS (dm-0): log I/O error -5
[ 457.438998] XFS (dm-0): Filesystem has been shut down due to log
error (0x2).
[ 457.439005] XFS (dm-0): Please unmount the filesystem and rectify the
problem(s).
With patch, reference count of nvme is 6 after system boots up.
2 paths for nvme0 and 4 paths for nvme1:
Can't do "rmmod nvme" command now.
#lsmod|grep nvme
# lsmod|grep nvme
nvme_tcp 262144 0
nvme 262144 6
nvme_fabrics 262144 1 nvme_tcp
nvme_core 458752 7 nvme_tcp,nvme,nvme_fabrics
nvme_keyring 262144 3 nvme_tcp,nvme_core,nvme_fabrics
nvme_auth 262144 1 nvme_core
# rmmod nvme
rmmod: ERROR: Module nvme is in use
If I remove 1 NS nvme device, reference count decreases 6 – 2 = 4 paths
in total.
# lsmod|grep nvme
nvme_tcp 262144 0
nvme 262144 4
nvme_fabrics 262144 1 nvme_tcp
nvme_core 458752 7 nvme_tcp,nvme,nvme_fabrics
nvme_keyring 262144 3 nvme_tcp,nvme_core,nvme_fabrics
nvme_auth 262144 1 nvme_core
If you need any additional information or have any other considerations,
please let me know.
Could you please help review the patch and share any feedback?
Thanks,
Wen
next prev parent reply other threads:[~2026-08-24 20:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 22:32 [PATCH V2] nvme: Add module reference counting for multipath devices wenxiong
2026-08-20 4:19 ` Nares Bannoth
2026-08-23 0:20 ` Sagi Grimberg
2026-08-23 0:46 ` Sagi Grimberg
2026-08-24 20:23 ` Wen Xiong [this message]
2026-08-25 19:11 ` Wen Xiong
2026-08-30 21:46 ` Sagi Grimberg
2026-08-26 12:40 ` Nilay Shroff
2026-08-26 14:23 ` Keith Busch
2026-08-26 16:18 ` Wen Xiong
2026-08-26 16:36 ` Keith Busch
2026-08-27 13:21 ` Nilay Shroff
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=af79f498b1287a3304db97477452537f@linux.ibm.com \
--to=wenxiong@linux.ibm.com \
--cc=gjoyce@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=wenxiong@us.ibm.com \
/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