From 9e378073994d2cfc822e529c1527c711fcdcc9a1 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Sun, 3 Mar 2019 22:18:05 -0500 Subject: [PATCH] nvme: free probe context for asynchronous probe API Free the probe context after the controllers in the probe context list become READY. Then users don't need to free the context which is allocated by SPDK driver. Change-Id: I2dcb76bacf26a401b5b559c4326764a4ddb97e83 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446820 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- include/spdk/nvme.h | 4 ++-- lib/nvme/nvme.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index e7de9a05d..8c6f4c2ad 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -612,8 +612,8 @@ struct spdk_nvme_probe_ctx *spdk_nvme_probe_async(const struct spdk_nvme_transpo * * \param probe_ctx Context used to track probe actions. * - * \return true if all probe operations are complete; the probe_ctx may be - * discarded at this point. + * \return true if all probe operations are complete; the probe_ctx + * is also freed and no longer valid. * \return false if there are still pending probe operations; user must call * spdk_nvme_probe_poll_async again to continue progress. */ diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index 4bb172de9..a148c9bd2 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -1098,6 +1098,7 @@ spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx) struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp; if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { + free(probe_ctx); return true; } @@ -1109,6 +1110,7 @@ spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx) nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock); g_spdk_nvme_driver->initialized = true; nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); + free(probe_ctx); return true; } return false;