From: Wen Xiong <wenxiong@linux.ibm.com>
To: John Garry <john.g.garry@oracle.com>
Cc: linux-nvme@lists.infradead.org, kbusch@kernel.org,
gjoyce@linux.ibm.com, wenxiong@us.ibm.com
Subject: Re: [PATCH] nvme: Add module reference counting for multipath nvme device
Date: Tue, 11 Aug 2026 13:54:06 -0500 [thread overview]
Message-ID: <936b1d36a4292c9501eec5a5df3d7b47@linux.ibm.com> (raw)
In-Reply-To: <92d55da9-2cb6-43aa-8fee-51f2c86101f8@oracle.com>
On 2026-08-11 08:18, John Garry wrote:
> Can you demonstrate that this is a problem?
>
For example, the Linux root filesystem is located on a multipath NVMe
device. During system boot, the reference count of the nvme module is
zero. As a result, the tester can run rmmod nvme, which causes the
system to become unstable or crash.
linux was installed on /dev/nvme4n2.
#lsmod|grep nvme
nvme_fabrics 262144 0
nvme 262144 0 ----> reference count = 0 for nvme
module.
nvme_core 458752 4 nvme,nvme_fabrics
nvme_keyring 262144 2 nvme_core,nvme_fabrics
nvme_auth 262144 1 nvme_core
# rmmod nvme
[11312.100786][ T937] BTRFS error (device nvme4n1p2): bdev
/dev/nvme4n1p2 errs: wr 1, rd 0, flush 0, corrupt 0, gen 0
[11312.100855][ T937] BTRFS error (device nvme4n1p2): bdev
/dev/nvme4n1p2 errs: wr 2, rd 0, flush 0, corrupt 0, gen 0
[11338.724061][ T624] BTRFS error (device nvme4n1p2 state A):
Transaction aborted (error -5)
[11338.724075][ T624] BTRFS: error (device nvme4n1p2 state A) in
__btrfs_update_delayed_inode:1096: errno=-5 IO failure
# ls
ls: reading directory '.': Input/output error
In the current nvme module reference count increase/decrease logic, the
operation is skipped when the device is a multipath device. As a result,
the NVMe module reference count remains zero even though the NVMe device
is actively being used by the multipath stack.
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)))
goto fail;
if (!nvme_get_ns(ns))
goto fail;
if (!try_module_get(ns->ctrl->ops->module))
goto fail_put_ns;
This patch adds module reference count increase/decrease logic in
nvme_ns_head_open() and nvme_ns_head_release() for the multipath head
device. This mirrors the behavior of nvme_ns_open() for non-multipath
devices.
Thanks,
Wendy
next prev parent reply other threads:[~2026-08-11 18:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 23:50 [PATCH] nvme: Add module reference counting for multipath nvme device wenxiong
2026-08-11 13:18 ` John Garry
2026-08-11 18:54 ` Wen Xiong [this message]
2026-08-11 19:12 ` Keith Busch
2026-08-11 20:33 ` Wen Xiong
2026-08-11 20:49 ` Keith Busch
2026-08-12 3:59 ` Wen Xiong
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=936b1d36a4292c9501eec5a5df3d7b47@linux.ibm.com \
--to=wenxiong@linux.ibm.com \
--cc=gjoyce@linux.ibm.com \
--cc=john.g.garry@oracle.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--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