nvme: add the asynchronous controllers probe/poll APIs
User can create a probe context to probe and attach controllers asynchronously, the controllers will be added to the context list for the first step, then users can poll the context until the list becomes empty. Change-Id: I3a96e2d8a9724332ff15542f78f9553fdab505e2 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/442664 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
3306e49e24
commit
bad30d5366
@ -2,6 +2,11 @@
|
||||
|
||||
## v19.04: (Upcoming Release)
|
||||
|
||||
### nvme
|
||||
|
||||
Added asynchronous probe support. New APIs spdk_nvme_probe_ctx_init(), spdk_nvme_probe_async()
|
||||
and spdk_nvme_probe_poll_async() were added to enable this feature.
|
||||
|
||||
### raid
|
||||
|
||||
Added new strip_size_kb rpc param on create to replace the more ambiguous
|
||||
|
@ -600,6 +600,32 @@ void spdk_nvme_probe_ctx_init(struct spdk_nvme_probe_ctx *probe_ctx,
|
||||
spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb);
|
||||
|
||||
/**
|
||||
* Probe and add controllers to the probe context list.
|
||||
*
|
||||
* Users must call spdk_nvme_probe_poll_async() to initialize
|
||||
* controllers in the probe context list to the READY state.
|
||||
*
|
||||
* \param probe_ctx Context used to track probe actions.
|
||||
*
|
||||
* \return 0 on success, -1 on failure.
|
||||
*/
|
||||
int spdk_nvme_probe_async(struct spdk_nvme_probe_ctx *probe_ctx);
|
||||
|
||||
/**
|
||||
* Start controllers in the context list.
|
||||
*
|
||||
* Users may call the function util it returns True.
|
||||
*
|
||||
* \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 false if there are still pending probe operations; user must call
|
||||
* spdk_nvme_probe_poll_async again to continue progress.
|
||||
*/
|
||||
bool spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx);
|
||||
|
||||
/**
|
||||
* Detach specified device returned by spdk_nvme_probe()'s attach_cb from the
|
||||
* NVMe driver.
|
||||
|
@ -1065,4 +1065,39 @@ spdk_nvme_probe_ctx_init(struct spdk_nvme_probe_ctx *probe_ctx,
|
||||
TAILQ_INIT(&probe_ctx->init_ctrlrs);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_probe_async(struct spdk_nvme_probe_ctx *probe_ctx)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = nvme_driver_init();
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return spdk_nvme_probe_internal(probe_ctx, false);
|
||||
}
|
||||
|
||||
bool
|
||||
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) {
|
||||
TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
|
||||
nvme_ctrlr_poll_internal(ctrlr, probe_ctx);
|
||||
}
|
||||
|
||||
if (TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) {
|
||||
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||
g_spdk_nvme_driver->initialized = true;
|
||||
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
||||
|
Loading…
x
Reference in New Issue
Block a user