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 <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446820
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Changpeng Liu 2019-03-03 22:18:05 -05:00
parent 030fb5e2bb
commit 9e37807399
2 changed files with 4 additions and 2 deletions

View File

@ -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. * \param probe_ctx Context used to track probe actions.
* *
* \return true if all probe operations are complete; the probe_ctx may be * \return true if all probe operations are complete; the probe_ctx
* discarded at this point. * is also freed and no longer valid.
* \return false if there are still pending probe operations; user must call * \return false if there are still pending probe operations; user must call
* spdk_nvme_probe_poll_async again to continue progress. * spdk_nvme_probe_poll_async again to continue progress.
*/ */

View File

@ -1098,6 +1098,7 @@ spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx)
struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp; struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
free(probe_ctx);
return true; 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); nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
g_spdk_nvme_driver->initialized = true; g_spdk_nvme_driver->initialized = true;
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
free(probe_ctx);
return true; return true;
} }
return false; return false;