[PATCH] nvme: Add module reference counting for multipath nvme device
Keith Busch
kbusch at kernel.org
Tue Aug 11 13:49:48 PDT 2026
On Tue, Aug 11, 2026 at 03:33:19PM -0500, Wen Xiong wrote:
> On 2026-08-11 14:12, Keith Busch wrote:
>
>
> > The result of nvme_find_path() is just the current path at the moment,
> > so I don't think this is right.
> >
> I thought:
> - if policy is NUMA, returns current caches path if optimized.
> - Otherwise scans other paths to find a new optimal path.
Let's say one path is rdma and the other is tcp. At the time you open,
the RDMA is the current optimal path, so you take a reference on the
nvme-rdma module. But while using this multipath device, the RDMA
connection is lost, so we failover to the TCP path. When you close the
multipath device, you find the TCP path, and then drop a reference on
the nvme-tcp module, leaking the RDMA reference, and underflowing TCP.
> > I think you need the head to hold a module reference on every path the
> > head has, so the module_get/put should be in nvme_mpath_add_disk and
> > nvme_mpath_remove_disk.
> I will check this.
Just a note, unlike I initially thought, nvme_mpath_remove_disk() is not
the mirror teardown function to nvme_mpath_add_disk(), so the path's
module reference put will have to be somewhere else, like
nvme_mpath_remove_sysfs_link().
More information about the Linux-nvme
mailing list