aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2012-11-06 13:59:23 -0500
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2012-11-13 09:13:50 -0500
commit2b1960341576bf51c01b12fefeb1cc53820923e7 (patch)
treeb04dab3e3bcc798ddc88fae6886271d540e72dff
parent6ecec74520d8a357726e6c12f99080dbe7b347dd (diff)
NVMe: Initialize iod nents to 0
For commands that do not map a scatter list, we need to initilaize the iod's number of sg entries (nents) to 0 and not unmap in this case. Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
-rw-r--r--drivers/block/nvme.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 270805cf8d42..993c014d195a 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -337,6 +337,7 @@ nvme_alloc_iod(unsigned nseg, unsigned nbytes, gfp_t gfp)
337 iod->offset = offsetof(struct nvme_iod, sg[nseg]); 337 iod->offset = offsetof(struct nvme_iod, sg[nseg]);
338 iod->npages = -1; 338 iod->npages = -1;
339 iod->length = nbytes; 339 iod->length = nbytes;
340 iod->nents = 0;
340 } 341 }
341 342
342 return iod; 343 return iod;
@@ -377,7 +378,8 @@ static void bio_completion(struct nvme_dev *dev, void *ctx,
377 struct bio *bio = iod->private; 378 struct bio *bio = iod->private;
378 u16 status = le16_to_cpup(&cqe->status) >> 1; 379 u16 status = le16_to_cpup(&cqe->status) >> 1;
379 380
380 dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents, 381 if (iod->nents)
382 dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents,
381 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 383 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
382 nvme_free_iod(dev, iod); 384 nvme_free_iod(dev, iod);
383 if (status) { 385 if (status) {