From c7c69c7cc13352b7fd2c8c603721e73b170e6101 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 15 Apr 2021 21:24:41 +0800 Subject: [PATCH] nvmf/vfio-user: consolidate request free function Also rename transport request and controller variables with "vu_" prefix. The consolidated function will be used in coming patch. Change-Id: I5219c13d7089dfdaea4a54e0b15cc5e6ecf2eb16 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7433 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 4554fdbc4..039439ca7 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -2062,18 +2062,24 @@ nvmf_vfio_user_poll_group_remove(struct spdk_nvmf_transport_poll_group *group, return 0; } +static void +_nvmf_vfio_user_req_free(struct nvmf_vfio_user_qpair *vu_qpair, struct nvmf_vfio_user_req *vu_req) +{ + TAILQ_INSERT_TAIL(&vu_qpair->reqs, vu_req, link); +} + static int nvmf_vfio_user_req_free(struct spdk_nvmf_request *req) { - struct nvmf_vfio_user_qpair *qpair; - struct nvmf_vfio_user_req *vfio_user_req; + struct nvmf_vfio_user_qpair *vu_qpair; + struct nvmf_vfio_user_req *vu_req; assert(req != NULL); - vfio_user_req = SPDK_CONTAINEROF(req, struct nvmf_vfio_user_req, req); - qpair = SPDK_CONTAINEROF(vfio_user_req->req.qpair, struct nvmf_vfio_user_qpair, qpair); + vu_req = SPDK_CONTAINEROF(req, struct nvmf_vfio_user_req, req); + vu_qpair = SPDK_CONTAINEROF(req->qpair, struct nvmf_vfio_user_qpair, qpair); - TAILQ_INSERT_TAIL(&qpair->reqs, vfio_user_req, link); + _nvmf_vfio_user_req_free(vu_qpair, vu_req); return 0; } @@ -2081,21 +2087,21 @@ nvmf_vfio_user_req_free(struct spdk_nvmf_request *req) static int nvmf_vfio_user_req_complete(struct spdk_nvmf_request *req) { - struct nvmf_vfio_user_qpair *qpair; - struct nvmf_vfio_user_req *vfio_user_req; + struct nvmf_vfio_user_qpair *vu_qpair; + struct nvmf_vfio_user_req *vu_req; assert(req != NULL); - vfio_user_req = SPDK_CONTAINEROF(req, struct nvmf_vfio_user_req, req); - qpair = SPDK_CONTAINEROF(vfio_user_req->req.qpair, struct nvmf_vfio_user_qpair, qpair); + vu_req = SPDK_CONTAINEROF(req, struct nvmf_vfio_user_req, req); + vu_qpair = SPDK_CONTAINEROF(req->qpair, struct nvmf_vfio_user_qpair, qpair); - if (vfio_user_req->cb_fn != NULL) { - if (vfio_user_req->cb_fn(vfio_user_req, vfio_user_req->cb_arg) != 0) { - fail_ctrlr(qpair->ctrlr); + if (vu_req->cb_fn != NULL) { + if (vu_req->cb_fn(vu_req, vu_req->cb_arg) != 0) { + fail_ctrlr(vu_qpair->ctrlr); } } - TAILQ_INSERT_TAIL(&qpair->reqs, vfio_user_req, link); + _nvmf_vfio_user_req_free(vu_qpair, vu_req); return 0; }