[PATCH 16/19] nvme-multipath: add nvme_mpath_{add,delete}_ns()

Nilay Shroff nilay at linux.ibm.com
Mon Mar 2 04:48:41 PST 2026


On 2/25/26 9:10 PM, John Garry wrote:
> Add functions to call into the mpath_add_device() and mpath_delete_device()
> functions.
> 
> The per-NS gendisk pointer is used as the mpath_device disk pointer, which
> is used in libmultipath for references the per-path block device.
> 
> Signed-off-by: John Garry<john.g.garry at oracle.com>
> ---
>   drivers/nvme/host/multipath.c | 26 ++++++++++++++++++++++++++
>   drivers/nvme/host/nvme.h      |  8 ++++++++
>   2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 7ee0ad7bdfa26..bd96211123fee 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -982,6 +982,32 @@ void nvme_mpath_synchronize(struct nvme_ns_head *head)
>   	mpath_synchronize(mpath_disk->mpath_head);
>   }
>   
> +void nvme_mpath_add_ns(struct nvme_ns *ns)
> +{
> +	struct nvme_ns_head *head = ns->head;
> +	struct mpath_disk *mpath_disk = head->mpath_disk;
> +	struct mpath_head *mpath_head;
> +
> +	if (!mpath_disk)
> +		return;
> +
> +	mpath_head = mpath_disk->mpath_head;
> +
> +	ns->mpath_device.disk = ns->disk;
> +	mpath_add_device(mpath_head, &ns->mpath_device);
> +}

As we have now reference to mpath_device from struct nvme_ns
then why do we still maintain reference to ns->disk? We may
want to directly access path device disk using ns->mpath_device.disk,
makes sense?

Thanks,
--Nilay



More information about the Linux-nvme mailing list