提交 4fbeeb5c 编写于 作者: C Christoph Hellwig 提交者: Caspar Zhang

nvme-pci: do not build a scatterlist to map metadata

fix #29327388

commit 783b94bd9250478154904fa782d2cfc46336cdf6 upstream

We always have exactly one segment, so we can simply call dma_map_bvec.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NKeith Busch <keith.busch@intel.com>
Reviewed-by: NSagi Grimberg <sagi@grimberg.me>
Reviewed-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: NBaolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 1a1efe1d
......@@ -224,7 +224,7 @@ struct nvme_iod {
int npages; /* In the PRP list. 0 means small pool in use */
int nents; /* Used in scatterlist */
dma_addr_t first_dma;
struct scatterlist meta_sg; /* metadata requires single contiguous buffer */
dma_addr_t meta_dma;
struct scatterlist *sg;
struct scatterlist inline_sg[0];
};
......@@ -600,13 +600,14 @@ static void nvme_unmap_data(struct nvme_dev *dev, struct request *req)
dma_addr_t dma_addr = iod->first_dma, next_dma_addr;
int i;
if (iod->nents) {
dma_unmap_sg(dev->dev, iod->sg, iod->nents, dma_dir);
if (blk_integrity_rq(req))
dma_unmap_sg(dev->dev, &iod->meta_sg, 1, dma_dir);
if (blk_integrity_rq(req)) {
dma_unmap_page(dev->dev, iod->meta_dma,
rq_integrity_vec(req)->bv_len, dma_dir);
}
if (iod->nents)
dma_unmap_sg(dev->dev, iod->sg, iod->nents, dma_dir);
if (iod->npages == 0)
dma_pool_free(dev->prp_small_pool, nvme_pci_iod_list(req)[0],
dma_addr);
......@@ -862,19 +863,14 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
ret = BLK_STS_IOERR;
if (blk_integrity_rq(req)) {
if (blk_rq_count_integrity_sg(q, req->bio) != 1)
goto out;
sg_init_table(&iod->meta_sg, 1);
if (blk_rq_map_integrity_sg(q, req->bio, &iod->meta_sg) != 1)
iod->meta_dma = dma_map_bvec(dev->dev, rq_integrity_vec(req),
dma_dir, 0);
if (dma_mapping_error(dev->dev, iod->meta_dma))
goto out;
if (!dma_map_sg(dev->dev, &iod->meta_sg, 1, dma_dir))
goto out;
cmnd->rw.metadata = cpu_to_le64(iod->meta_dma);
}
if (blk_integrity_rq(req))
cmnd->rw.metadata = cpu_to_le64(sg_dma_address(&iod->meta_sg));
return BLK_STS_OK;
out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册