[PATCH 4/4] nvme: add mulitipath warning to nvme_alloc_ns

John Meneghini posted 4 patches 1 year, 1 month ago
There is a newer version of this series
[PATCH 4/4] nvme: add mulitipath warning to nvme_alloc_ns
Posted by John Meneghini 1 year, 1 month ago
When CONFIG_NVME_MULTIPATH is disabled, add a warning if
we discover a multipath enabled controller with an attached
shared namespace.

Signed-off-by: John Meneghini <jmeneghi@redhat.com>
---
 drivers/nvme/host/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c2b7e6834535..465069c0f6a8 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3938,6 +3938,15 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
 	} else {
 		sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance,
 			ns->head->instance);
+#ifndef CONFIG_NVME_MULTIPATH
+		if ((ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && info->is_shared) {
+			dev_warn(ctrl->device,
+				"Found shared namespace %d but multipathing not supported.\n",
+				info->nsid);
+			dev_warn_once(ctrl->device,
+				"Shared namespace support requires CONFIG_NVME_MULTIPATH.\n");
+		}
+#endif
 	}
 
 	if (nvme_update_ns_info(ns, info))
-- 
2.48.1
Re: [PATCH 4/4] nvme: add mulitipath warning to nvme_alloc_ns
Posted by Christoph Hellwig 1 year ago
On Thu, Feb 27, 2025 at 10:25:41PM -0500, John Meneghini wrote:
> When CONFIG_NVME_MULTIPATH is disabled, add a warning if
> we discover a multipath enabled controller with an attached
> shared namespace.
> 
> Signed-off-by: John Meneghini <jmeneghi@redhat.com>
> ---
>  drivers/nvme/host/core.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index c2b7e6834535..465069c0f6a8 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3938,6 +3938,15 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
>  	} else {
>  		sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance,
>  			ns->head->instance);
> +#ifndef CONFIG_NVME_MULTIPATH

This can use IS_ENABLED to clean the code up a bit.

> +		if ((ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && info->is_shared) {

overly long line.