From 7abbad3ccfd6c8dc83aba71927d8708fe89a8abc Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 15 Apr 2021 21:28:56 +0800 Subject: [PATCH] nvmf/vfio-user: reset the request internal fields in the completion callback Previously we reset them when getting a new request, but it's more reasonable in the completion path. Change-Id: I3dab35ce471d2a5bbd37576540d30a09dcf93410 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7434 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 039439ca70..11abf6f9ab 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -2065,6 +2065,10 @@ nvmf_vfio_user_poll_group_remove(struct spdk_nvmf_transport_poll_group *group, static void _nvmf_vfio_user_req_free(struct nvmf_vfio_user_qpair *vu_qpair, struct nvmf_vfio_user_req *vu_req) { + memset(&vu_req->cmd, 0, sizeof(vu_req->cmd)); + memset(&vu_req->rsp, 0, sizeof(vu_req->rsp)); + vu_req->iovcnt = 0; + TAILQ_INSERT_TAIL(&vu_qpair->reqs, vu_req, link); } @@ -2137,9 +2141,6 @@ get_nvmf_vfio_user_req(struct nvmf_vfio_user_qpair *qpair) req = TAILQ_FIRST(&qpair->reqs); TAILQ_REMOVE(&qpair->reqs, req, link); - memset(&req->cmd, 0, sizeof(req->cmd)); - memset(&req->rsp, 0, sizeof(req->rsp)); - req->iovcnt = 0; return req; }