Skip to content

Commit d39ad2a

Browse files
keithbuschChristoph Hellwig
authored andcommitted
nvme: disable namespace access for unsupported metadata
The only fabrics target that supports metadata handling through the separate integrity buffer is RDMA. It is currently usable only if the size 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 through the block stack, but will continue to allow ioctl passthrough commands. Cc: Max Gurtovoy <[email protected]> Cc: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 16cc33b commit d39ad2a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/nvme/host/core.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,9 +1749,20 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
17491749
*/
17501750
if (WARN_ON_ONCE(!(id->flbas & NVME_NS_FLBAS_META_EXT)))
17511751
return -EINVAL;
1752-
if (ctrl->max_integrity_segments)
1753-
ns->features |=
1754-
(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
1752+
1753+
ns->features |= NVME_NS_EXT_LBAS;
1754+
1755+
/*
1756+
* The current fabrics transport drivers support namespace
1757+
* metadata formats only if nvme_ns_has_pi() returns true.
1758+
* Suppress support for all other formats so the namespace will
1759+
* have a 0 capacity and not be usable through the block stack.
1760+
*
1761+
* Note, this check will need to be modified if any drivers
1762+
* gain the ability to use other metadata formats.
1763+
*/
1764+
if (ctrl->max_integrity_segments && nvme_ns_has_pi(ns))
1765+
ns->features |= NVME_NS_METADATA_SUPPORTED;
17551766
} else {
17561767
/*
17571768
* For PCIe controllers, we can't easily remap the separate

0 commit comments

Comments
 (0)