[PATCH] nvme: improve check for attached metadata buffers

Christoph Hellwig hch at lst.de
Mon Nov 6 11:01:52 PST 2017


Remove a convoluted check for metadata enabled namespaces, and
turn it into a debug assert that the block layer always attaches
metadata in this case, as it should.

Reported-by: Javier González <javier at cnexlabs.com>
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 64744355aa88..7b413d5480cf 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -476,14 +476,11 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
 	u32 dsmgmt = 0;
 
 	/*
-	 * If formated with metadata, require the block layer provide a buffer
-	 * unless this namespace is formated such that the metadata can be
-	 * stripped/generated by the controller with PRACT=1.
+	 * The block layer should always provide a metadata buffer if the
+	 * namespace is formatted with metadata.
 	 */
-	if (ns && ns->ms &&
-	    (!ns->pi_type || ns->ms != sizeof(struct t10_pi_tuple)) &&
-	    !blk_integrity_rq(req) && !blk_rq_is_passthrough(req))
-		return BLK_STS_NOTSUPP;
+	if (WARN_ON_ONCE(ns->ms && !blk_integrity_rq(req)))
+		return BLK_STS_IOERR;
 
 	if (req->cmd_flags & REQ_FUA)
 		control |= NVME_RW_FUA;
-- 
2.14.2




More information about the Linux-nvme mailing list