Skip to content

Commit 8446546

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme-rdma: factor out a nvme_rdma_end_request helper
Factor a small sniplet of duplicated code into a new helper in preparation for making this sniplet a little bit less trivial. Reviewed-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 40d09b5 commit 8446546

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

drivers/nvme/host/rdma.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,15 @@ static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl)
11491149
queue_work(nvme_reset_wq, &ctrl->err_work);
11501150
}
11511151

1152+
static void nvme_rdma_end_request(struct nvme_rdma_request *req)
1153+
{
1154+
struct request *rq = blk_mq_rq_from_pdu(req);
1155+
1156+
if (!refcount_dec_and_test(&req->ref))
1157+
return;
1158+
nvme_end_request(rq, req->status, req->result);
1159+
}
1160+
11521161
static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc,
11531162
const char *op)
11541163
{
@@ -1173,16 +1182,11 @@ static void nvme_rdma_inv_rkey_done(struct ib_cq *cq, struct ib_wc *wc)
11731182
{
11741183
struct nvme_rdma_request *req =
11751184
container_of(wc->wr_cqe, struct nvme_rdma_request, reg_cqe);
1176-
struct request *rq = blk_mq_rq_from_pdu(req);
11771185

1178-
if (unlikely(wc->status != IB_WC_SUCCESS)) {
1186+
if (unlikely(wc->status != IB_WC_SUCCESS))
11791187
nvme_rdma_wr_error(cq, wc, "LOCAL_INV");
1180-
return;
1181-
}
1182-
1183-
if (refcount_dec_and_test(&req->ref))
1184-
nvme_end_request(rq, req->status, req->result);
1185-
1188+
else
1189+
nvme_rdma_end_request(req);
11861190
}
11871191

11881192
static int nvme_rdma_inv_rkey(struct nvme_rdma_queue *queue,
@@ -1547,15 +1551,11 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
15471551
container_of(wc->wr_cqe, struct nvme_rdma_qe, cqe);
15481552
struct nvme_rdma_request *req =
15491553
container_of(qe, struct nvme_rdma_request, sqe);
1550-
struct request *rq = blk_mq_rq_from_pdu(req);
15511554

1552-
if (unlikely(wc->status != IB_WC_SUCCESS)) {
1555+
if (unlikely(wc->status != IB_WC_SUCCESS))
15531556
nvme_rdma_wr_error(cq, wc, "SEND");
1554-
return;
1555-
}
1556-
1557-
if (refcount_dec_and_test(&req->ref))
1558-
nvme_end_request(rq, req->status, req->result);
1557+
else
1558+
nvme_rdma_end_request(req);
15591559
}
15601560

15611561
static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
@@ -1694,11 +1694,9 @@ static void nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,
16941694
nvme_rdma_error_recovery(queue->ctrl);
16951695
}
16961696
/* the local invalidation completion will end the request */
1697-
return;
1697+
} else {
1698+
nvme_rdma_end_request(req);
16981699
}
1699-
1700-
if (refcount_dec_and_test(&req->ref))
1701-
nvme_end_request(rq, req->status, req->result);
17021700
}
17031701

17041702
static void nvme_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc)

0 commit comments

Comments
 (0)