nvme-pci: only call nvme_unmap_data for requests transferring data
authorChristoph Hellwig <hch@lst.de>
Sun, 3 Mar 2019 15:52:21 +0000 (08:52 -0700)
committerChristoph Hellwig <hch@lst.de>
Fri, 5 Apr 2019 06:07:57 +0000 (08:07 +0200)
This mirrors how nvme_map_pci is called and will allow simplifying some
checks in nvme_unmap_pci later on.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
drivers/nvme/host/pci.c

index de199aff8d0569bef086c0d326df4b0fd5af133f..030ee94452dd106c676eeae758fc825760807624 100644 (file)
@@ -929,7 +929,8 @@ static void nvme_pci_complete_rq(struct request *req)
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
 
        nvme_cleanup_cmd(req);
-       nvme_unmap_data(iod->nvmeq->dev, req);
+       if (blk_rq_nr_phys_segments(req))
+               nvme_unmap_data(iod->nvmeq->dev, req);
        nvme_complete_rq(req);
 }