From: Nares Bannoth <nbannoth@linux.ibm.com>
To: wenxiong@linux.ibm.com, linux-nvme@lists.infradead.org,
kbusch@kernel.org
Cc: gjoyce@linux.ibm.com, wenxiong@us.ibm.com, venkat88@linux.ibm.com
Subject: Re: [PATCH V2] nvme: Add module reference counting for multipath devices
Date: Thu, 20 Aug 2026 09:49:14 +0530 [thread overview]
Message-ID: <4311bf7d-3f88-4a99-8ce3-5b435f90b48e@linux.ibm.com> (raw)
In-Reply-To: <20260812223206.720363-1-wenxiong@linux.ibm.com>
On 13/08/26 4:02 am, wenxiong@linux.ibm.com wrote:
> From: Wen Xiong <wenxiong@linux.ibm.com>
>
> Add proper module reference counting to prevent premature unloading of
> NVMe transport modules while multipath namespaces are still active.
>
> When a namespace is added to a multipath device via nvme_mpath_add_disk(),
> the underlying transport module (PCIe, FC, RDMA, TCP, etc.) must remain
> loaded as long as the multipath device references that namespace. Without
> proper reference counting, the transport module could be unloaded while
> the multipath device is still using resources from that module, leading
> to the potential system crashes.
>
> This ensures the transport module remains loaded for the entire lifetime
> of the multipath namespace association.
>
> Signed-off-by: Wen Xiong <wenxiong@linux.ibm.com>
> ---
Hi Wen,
I tested this patch and it is working as expected.
Patch Validation Results
--------------------------------
# lsmod | grep -i nvme
nvme_tcp 262144 0
nvme 262144 9
nvme_fabrics 262144 1 nvme_tcp
nvme_core 458752 8 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.
#
# rmmod nvme_tcp
#
# lsmod | grep -i nvme
nvme 262144 9
nvme_fabrics 262144 0
nvme_core 458752 7 nvme,nvme_fabrics
nvme_keyring 262144 2 nvme_core,nvme_fabrics
nvme_auth 262144 1 nvme_core
# rmmod nvme_core
rmmod: ERROR: Module nvme_core is in use by: nvme nvme_fabrics
#
# rmmod nvme_fabrics
#
# rmmod nvme_core
rmmod: ERROR: Module nvme_core is in use by: nvme
#
# lsmod | grep -i nvme
nvme 262144 9
nvme_core 458752 6 nvme
nvme_keyring 262144 1 nvme_core
nvme_auth 262144 1 nvme_core
#
Please add below tag :
Tested-by: Naresh Bannoth <nbannoth@linux.ibm.com>
Thanks and Regards,
Naresh.
> drivers/nvme/host/multipath.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 9b9a657fa330..707b8f95727d 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -1348,6 +1348,8 @@ void nvme_mpath_remove_sysfs_link(struct nvme_ns *ns)
> sysfs_remove_link_from_group(kobj, nvme_ns_mpath_attr_group.name,
> dev_name(target));
> clear_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags);
> +
> + module_put(ns->ctrl->ops->module);
> }
>
> void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid)
> @@ -1379,6 +1381,9 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid)
> if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
> ns->head->disk->nr_zones = ns->disk->nr_zones;
> #endif
> + if (!try_module_get(ns->ctrl->ops->module))
> + dev_err(disk_to_dev(ns->disk),
> + "Failed to get module reference\n");
> }
>
> void nvme_mpath_remove_disk(struct nvme_ns_head *head)
next prev parent reply other threads:[~2026-08-20 4:19 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 [this message]
2026-08-23 0:20 ` Sagi Grimberg
2026-08-23 0:46 ` Sagi Grimberg
2026-08-24 20:23 ` Wen Xiong
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=4311bf7d-3f88-4a99-8ce3-5b435f90b48e@linux.ibm.com \
--to=nbannoth@linux.ibm.com \
--cc=gjoyce@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=venkat88@linux.ibm.com \
--cc=wenxiong@linux.ibm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.