All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] nvme: disable namespaces with unsupported metadata
@ 2021-11-29 16:07 Keith Busch
  2021-11-29 22:33 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2021-11-29 16:07 UTC (permalink / raw)
  To: linux-nvme, hch; +Cc: Keith Busch, Max Gurtovoy, Sagi Grimberg

The only fabrics target that supports metadata is RDMA and usable only
if it is 8B per block, and formatted for protection information. If an
rdma target were to export a namespace with a different format (ex:
4k+64B), the driver will not be able to submit valid read/write commands
for that namespace.

Suppress setting the metadata feature in the namespace so that the
gendisk capacity will be set to 0. This will prevent read/write access.

Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v1->v2: changelog and comment updates

 drivers/nvme/host/core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4b5de8f5435a..47a941207058 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1740,7 +1740,18 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
 		 */
 		if (WARN_ON_ONCE(!(id->flbas & NVME_NS_FLBAS_META_EXT)))
 			return -EINVAL;
-		if (ctrl->max_integrity_segments)
+
+		/*
+		 * The current fabrics transport drivers support namespace
+		 * metadata formats only if nvme_ns_has_pi() returns true.
+		 * Suppress setting the feature for all other formats so the
+		 * namespace will have a 0 capacity and not be usable through
+		 * the block stack.
+		 *
+		 * Note, this check will need to be modified if any drivers
+		 * gain the ability to use other metadata formats.
+		 */
+		if (ctrl->max_integrity_segments && nvme_ns_has_pi(ns))
 			ns->features |=
 				(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
 	} else {
-- 
2.25.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCHv2] nvme: disable namespaces with unsupported metadata
  2021-11-29 16:07 [PATCHv2] nvme: disable namespaces with unsupported metadata Keith Busch
@ 2021-11-29 22:33 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2021-11-29 22:33 UTC (permalink / raw)
  To: linux-nvme, hch; +Cc: Max Gurtovoy, Sagi Grimberg

On Mon, Nov 29, 2021 at 08:07:12AM -0800, Keith Busch wrote:
> +		if (ctrl->max_integrity_segments && nvme_ns_has_pi(ns))
>  			ns->features |=
>  				(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);

Apparently the passthrough interface works fine for any arbitrary
metadata format, so looks like we should leave NVME_NS_EXT_LBAS flag set
for all transports. I'll need to send a v3.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-29 22:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 16:07 [PATCHv2] nvme: disable namespaces with unsupported metadata Keith Busch
2021-11-29 22:33 ` Keith Busch

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.