Make the error flow symmetric to the good flow by moving the call to
nvme_cleanup_cmd from nvme_rdma_unmap_data function.

Signed-off-by: Max Gurtovoy <[email protected]>
---
 drivers/nvme/host/rdma.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 1a6449b..db4a60f 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1149,7 +1149,6 @@ static void nvme_rdma_unmap_data(struct nvme_rdma_queue 
*queue,
                        req->nents, rq_data_dir(rq) ==
                                    WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
 
-       nvme_cleanup_cmd(rq);
        sg_free_table_chained(&req->sg_table, SG_CHUNK_SIZE);
 }
 
@@ -1748,7 +1747,6 @@ static blk_status_t nvme_rdma_queue_rq(struct 
blk_mq_hw_ctx *hctx,
        if (unlikely(err < 0)) {
                dev_err(queue->ctrl->ctrl.device,
                             "Failed to map data (%d)\n", err);
-               nvme_cleanup_cmd(rq);
                goto err;
        }
 
@@ -1759,18 +1757,19 @@ static blk_status_t nvme_rdma_queue_rq(struct 
blk_mq_hw_ctx *hctx,
 
        err = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge,
                        req->mr ? &req->reg_wr.wr : NULL);
-       if (unlikely(err)) {
-               nvme_rdma_unmap_data(queue, rq);
-               goto err;
-       }
+       if (unlikely(err))
+               goto err_unmap;
 
        return BLK_STS_OK;
 
+err_unmap:
+       nvme_rdma_unmap_data(queue, rq);
 err:
        if (err == -ENOMEM || err == -EAGAIN)
                ret = BLK_STS_RESOURCE;
        else
                ret = BLK_STS_IOERR;
+       nvme_cleanup_cmd(rq);
 unmap_qe:
        ib_dma_unmap_single(dev, req->sqe.dma, sizeof(struct nvme_command),
                            DMA_TO_DEVICE);
@@ -1791,6 +1790,7 @@ static void nvme_rdma_complete_rq(struct request *rq)
        struct ib_device *ibdev = queue->device->dev;
 
        nvme_rdma_unmap_data(queue, rq);
+       nvme_cleanup_cmd(rq);
        ib_dma_unmap_single(ibdev, req->sqe.dma, sizeof(struct nvme_command),
                            DMA_TO_DEVICE);
        nvme_complete_rq(rq);
-- 
1.8.3.1

Reply via email to