Commit 71feb364 authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

NVMe: Fix IO for extended metadata formats

This fixes io submit ioctl handling when using extended metadata
formats. When these formats are used, the user provides a single virtually
contiguous buffer containing both the block and metadata interleaved,
so the metadata size needs to be added to the total length and not mapped
as a separate transfer.

The command is also driver generated, so this patch does not enforce
blk-integrity extensions provide the metadata buffer.
Reported-by: default avatarMarcin Dziegielewski <marcin.dziegielewski@intel.com>
Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent e112af0d
...@@ -852,7 +852,8 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx, ...@@ -852,7 +852,8 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
* stripped/generated by the controller with PRACT=1. * stripped/generated by the controller with PRACT=1.
*/ */
if (ns && ns->ms && !blk_integrity_rq(req)) { if (ns && ns->ms && !blk_integrity_rq(req)) {
if (!(ns->pi_type && ns->ms == 8)) { if (!(ns->pi_type && ns->ms == 8) &&
req->cmd_type != REQ_TYPE_DRV_PRIV) {
req->errors = -EFAULT; req->errors = -EFAULT;
blk_mq_complete_request(req); blk_mq_complete_request(req);
return BLK_MQ_RQ_QUEUE_OK; return BLK_MQ_RQ_QUEUE_OK;
...@@ -1747,15 +1748,14 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) ...@@ -1747,15 +1748,14 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
meta_len = (io.nblocks + 1) * ns->ms; meta_len = (io.nblocks + 1) * ns->ms;
write = io.opcode & 1; write = io.opcode & 1;
if (ns->ext) {
length += meta_len;
meta_len = 0;
}
if (meta_len) { if (meta_len) {
if (((io.metadata & 3) || !io.metadata) && !ns->ext) if (((io.metadata & 3) || !io.metadata) && !ns->ext)
return -EINVAL; return -EINVAL;
if (ns->ext) {
length += meta_len;
meta_len = 0;
}
meta = dma_alloc_coherent(dev->dev, meta_len, meta = dma_alloc_coherent(dev->dev, meta_len,
&meta_dma, GFP_KERNEL); &meta_dma, GFP_KERNEL);
if (!meta) { if (!meta) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment