From 52f3c2fa520692e7f7d20d893ae4050eeab97b40 Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 6 Dec 2016 18:00:48 -0500 Subject: [PATCH] nvme: free IO qpair when cleaning up died process Change-Id: I136945b6bed4d2cdb0ee54b27b224c2e9cec377f Signed-off-by: GangCao --- lib/nvme/nvme_ctrlr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index a3346001e..f19bc0c0c 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -933,13 +933,15 @@ nvme_ctrlr_remove_process(struct spdk_nvme_ctrlr *ctrlr, /** * This function will be called when the process exited unexpectedly - * in order to free any incomplete nvme request and allocated memory. + * in order to free any incomplete nvme request, allocated IO qpairs + * and allocated memory. * Note: the ctrlr_lock must be held when calling this function. */ static void nvme_ctrlr_cleanup_process(struct spdk_nvme_ctrlr_process *proc) { struct nvme_request *req, *tmp_req; + struct spdk_nvme_qpair *qpair, *tmp_qpair; STAILQ_FOREACH_SAFE(req, &proc->active_reqs, stailq, tmp_req) { STAILQ_REMOVE(&proc->active_reqs, req, nvme_request, stailq); @@ -949,6 +951,12 @@ nvme_ctrlr_cleanup_process(struct spdk_nvme_ctrlr_process *proc) nvme_free_request(req); } + TAILQ_FOREACH_SAFE(qpair, &proc->allocated_io_qpairs, per_process_tailq, tmp_qpair) { + TAILQ_REMOVE(&proc->allocated_io_qpairs, qpair, per_process_tailq); + + spdk_nvme_ctrlr_free_io_qpair(qpair); + } + spdk_free(proc); }