nvme: move condition check into nvme_init_controllers()
Also use the same style condition check for secondary process with PCIE type. Change-Id: I93c83126145255887914ef5efea1a493c8f7f767 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/444492 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
97768b0773
commit
5a26346a71
@ -471,6 +471,10 @@ nvme_init_controllers(struct spdk_nvme_probe_ctx *probe_ctx)
|
||||
int rc = 0;
|
||||
struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
|
||||
|
||||
if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize all new controllers in the probe context init_ctrlrs list in parallel. */
|
||||
while (!TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) {
|
||||
TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
|
||||
@ -607,16 +611,11 @@ spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (spdk_process_is_primary() || trid->trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||
/*
|
||||
* Keep going even if one or more nvme_attach() calls failed,
|
||||
* but maintain the value of rc to signal errors when we return.
|
||||
*/
|
||||
|
||||
rc = nvme_init_controllers(&probe_ctx);
|
||||
}
|
||||
|
||||
return rc;
|
||||
/*
|
||||
* Keep going even if one or more nvme_attach() calls failed,
|
||||
* but maintain the value of rc to signal errors when we return.
|
||||
*/
|
||||
return nvme_init_controllers(&probe_ctx);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -665,11 +664,9 @@ spdk_nvme_connect(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_ctx_init(&probe_ctx, trid, user_connect_opts, probe_cb, NULL, NULL);
|
||||
spdk_nvme_probe_internal(&probe_ctx, true);
|
||||
|
||||
if (spdk_process_is_primary() || trid->trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||
rc = nvme_init_controllers(&probe_ctx);
|
||||
if (rc != 0) {
|
||||
return NULL;
|
||||
}
|
||||
rc = nvme_init_controllers(&probe_ctx);
|
||||
if (rc != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctrlr = spdk_nvme_get_ctrlr_by_trid(trid);
|
||||
@ -1083,21 +1080,21 @@ 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;
|
||||
if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
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;
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
||||
|
@ -281,10 +281,12 @@ test_nvme_init_controllers(void)
|
||||
* Verify correct behavior when it does.
|
||||
*/
|
||||
MOCK_SET(nvme_ctrlr_process_init, 1);
|
||||
MOCK_SET(spdk_process_is_primary, 1);
|
||||
g_spdk_nvme_driver->initialized = false;
|
||||
ut_destruct_called = false;
|
||||
probe_ctx.cb_ctx = cb_ctx;
|
||||
probe_ctx.attach_cb = attach_cb;
|
||||
probe_ctx.trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||
rc = nvme_init_controllers(&probe_ctx);
|
||||
CU_ASSERT(rc != 0);
|
||||
CU_ASSERT(g_spdk_nvme_driver->initialized == true);
|
||||
|
Loading…
Reference in New Issue
Block a user