[PATCH 07/14] nvmet: reuse pt-req-done for rq completion

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Mon Aug 10 14:54:49 EDT 2020


In the function nvmet_passthru_execute_cmd_work() after overriding
id_[ctr|ns] results it completes the request by assigning the target
request completion queue entry result from nvme request result,
actually completing request on the transport and calling
blk_mq_free_request().

The function nvmet_passhru_req_done does the same thing, use that and
remove the duplicate code in nvmet_passhru_execute_cmd_work().

The last parameter for the nvmet_passthru_req_done() which is
blk_status_t is not used since we derive the result from the nvme_req.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/passthru.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 00270e20c83a..0b18038c44bb 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -142,6 +142,15 @@ static u16 nvmet_passthru_override_id_ns(struct nvmet_req *req)
 	return status;
 }
 
+static void nvmet_passthru_req_done(struct request *rq, blk_status_t blk_sts)
+{
+	struct nvmet_req *req = rq->end_io_data;
+
+	req->cqe->result = nvme_req(rq)->result;
+	nvmet_req_complete(req, nvme_req(rq)->status);
+	blk_mq_free_request(rq);
+}
+
 static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
 {
 	struct nvmet_req *req = container_of(w, struct nvmet_req, p.work);
@@ -163,19 +172,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
 		}
 	}
 
-	req->cqe->result = nvme_req(rq)->result;
-	nvmet_req_complete(req, status);
-	blk_mq_free_request(rq);
-}
-
-static void nvmet_passthru_req_done(struct request *rq,
-				    blk_status_t blk_status)
-{
-	struct nvmet_req *req = rq->end_io_data;
-
-	req->cqe->result = nvme_req(rq)->result;
-	nvmet_req_complete(req, nvme_req(rq)->status);
-	blk_mq_free_request(rq);
+	rq->end_io_data = req;
+	nvmet_passthru_req_done(rq, 0 /* this value is not used for request */);
 }
 
 static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
-- 
2.22.1




More information about the Linux-nvme mailing list