From b21ffd2ee27a1dc25b506715722d21593e6b8bd7 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Mon, 31 Aug 2020 15:50:09 +0800 Subject: [PATCH] alinux: nvme: pci: Fix the incorrect ways to calculate the request size fix #29375191 For NVMe discard request, it will use special_vec to describe the size of the request, thus it will get an incorrect request size with blk_rq_bytes() when handling the NVMe discard request. Thus we should use blk_rq_payload_bytes() to calculate the data transfer size which can fix this issue. Fixes: 220741e8c12d ("alios: nvme-pci: Improve mapping single segment requests using SGLs") Signed-off-by: Baolin Wang Acked-by: Xiaoguang Wang Reviewed-by: Jiufei Xue --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 62bc81b610a2..f0298a324861 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -830,7 +830,7 @@ static blk_status_t nvme_setup_sgl_simple(struct nvme_dev *dev, struct bio_vec *bv) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - unsigned int length = blk_rq_bytes(req); + unsigned int length = blk_rq_payload_bytes(req); iod->first_dma = dma_map_page(dev->dev, bv->bv_page, bv->bv_offset, length, rq_dma_dir(req)); -- GitLab