stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] nvme: add missing unmaps in nvme_queue_rq
       [not found] <1444409756-7317-1-git-send-email-hch@lst.de>
@ 2015-10-09 16:55 ` Christoph Hellwig
  2015-10-09 23:46   ` Sagi Grimberg
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2015-10-09 16:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Keith Busch, linux-nvme, stable

When we fail various metadata related operations in nvme_queue_rq we
need to unmap the data SGL.

Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/pci.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a526696..0a85fab 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -904,19 +904,28 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 			goto retry_cmd;
 		}
 		if (blk_integrity_rq(req)) {
-			if (blk_rq_count_integrity_sg(req->q, req->bio) != 1)
+			if (blk_rq_count_integrity_sg(req->q, req->bio) != 1) {
+				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
+						dma_dir);
 				goto error_cmd;
+			}
 
 			sg_init_table(iod->meta_sg, 1);
 			if (blk_rq_map_integrity_sg(
-					req->q, req->bio, iod->meta_sg) != 1)
+					req->q, req->bio, iod->meta_sg) != 1) {
+				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
+						dma_dir);
 				goto error_cmd;
+			}
 
 			if (rq_data_dir(req))
 				nvme_dif_remap(req, nvme_dif_prep);
 
-			if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir))
+			if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir)) {
+				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
+						dma_dir);
 				goto error_cmd;
+			}
 		}
 	}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] nvme: add missing unmaps in nvme_queue_rq
  2015-10-09 16:55 ` [PATCH 1/3] nvme: add missing unmaps in nvme_queue_rq Christoph Hellwig
@ 2015-10-09 23:46   ` Sagi Grimberg
  2015-10-10  6:55     ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Sagi Grimberg @ 2015-10-09 23:46 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: Keith Busch, stable, linux-nvme

On 10/9/2015 7:55 PM, Christoph Hellwig wrote:
> When we fail various metadata related operations in nvme_queue_rq we
> need to unmap the data SGL.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/pci.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index a526696..0a85fab 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -904,19 +904,28 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
>   			goto retry_cmd;
>   		}
>   		if (blk_integrity_rq(req)) {
> -			if (blk_rq_count_integrity_sg(req->q, req->bio) != 1)
> +			if (blk_rq_count_integrity_sg(req->q, req->bio) != 1) {
> +				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
> +						dma_dir);
>   				goto error_cmd;
> +			}
>
>   			sg_init_table(iod->meta_sg, 1);
>   			if (blk_rq_map_integrity_sg(
> -					req->q, req->bio, iod->meta_sg) != 1)
> +					req->q, req->bio, iod->meta_sg) != 1) {
> +				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
> +						dma_dir);
>   				goto error_cmd;
> +			}
>
>   			if (rq_data_dir(req))
>   				nvme_dif_remap(req, nvme_dif_prep);
>
> -			if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir))
> +			if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir)) {
> +				dma_unmap_sg(dev->dev, iod->sg, iod->nents,
> +						dma_dir);
>   				goto error_cmd;
> +			}
>   		}
>   	}
>
>

Hi Christoph,

Would it be better to unmap the data sg once at error_cmd tag?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] nvme: add missing unmaps in nvme_queue_rq
  2015-10-09 23:46   ` Sagi Grimberg
@ 2015-10-10  6:55     ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2015-10-10  6:55 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: Christoph Hellwig, Jens Axboe, Keith Busch, stable, linux-nvme

On Sat, Oct 10, 2015 at 02:46:51AM +0300, Sagi Grimberg wrote:
> Would it be better to unmap the data sg once at error_cmd tag?

We'd need unmap versions of the error_cmd and retry_cmd goto labels,
which was too much churn for this quick fix.  Patch 3 now has a single
exit path with a ret variable for the helper this has been factored out
to, so this has been taken care off there.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-10  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1444409756-7317-1-git-send-email-hch@lst.de>
2015-10-09 16:55 ` [PATCH 1/3] nvme: add missing unmaps in nvme_queue_rq Christoph Hellwig
2015-10-09 23:46   ` Sagi Grimberg
2015-10-10  6:55     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).