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;
|
int rc = 0;
|
||||||
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) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize all new controllers in the probe context init_ctrlrs list in parallel. */
|
/* Initialize all new controllers in the probe context init_ctrlrs list in parallel. */
|
||||||
while (!TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) {
|
while (!TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) {
|
||||||
TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
|
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;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_process_is_primary() || trid->trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
|
||||||
/*
|
/*
|
||||||
* Keep going even if one or more nvme_attach() calls failed,
|
* Keep going even if one or more nvme_attach() calls failed,
|
||||||
* but maintain the value of rc to signal errors when we return.
|
* but maintain the value of rc to signal errors when we return.
|
||||||
*/
|
*/
|
||||||
|
return nvme_init_controllers(&probe_ctx);
|
||||||
rc = nvme_init_controllers(&probe_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -665,12 +664,10 @@ 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_ctx_init(&probe_ctx, trid, user_connect_opts, probe_cb, NULL, NULL);
|
||||||
spdk_nvme_probe_internal(&probe_ctx, true);
|
spdk_nvme_probe_internal(&probe_ctx, true);
|
||||||
|
|
||||||
if (spdk_process_is_primary() || trid->trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
|
||||||
rc = nvme_init_controllers(&probe_ctx);
|
rc = nvme_init_controllers(&probe_ctx);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ctrlr = spdk_nvme_get_ctrlr_by_trid(trid);
|
ctrlr = spdk_nvme_get_ctrlr_by_trid(trid);
|
||||||
|
|
||||||
@ -1083,7 +1080,10 @@ 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) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
|
TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
|
||||||
nvme_ctrlr_poll_internal(ctrlr, probe_ctx);
|
nvme_ctrlr_poll_internal(ctrlr, probe_ctx);
|
||||||
}
|
}
|
||||||
@ -1097,7 +1097,4 @@ spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
||||||
|
@ -281,10 +281,12 @@ test_nvme_init_controllers(void)
|
|||||||
* Verify correct behavior when it does.
|
* Verify correct behavior when it does.
|
||||||
*/
|
*/
|
||||||
MOCK_SET(nvme_ctrlr_process_init, 1);
|
MOCK_SET(nvme_ctrlr_process_init, 1);
|
||||||
|
MOCK_SET(spdk_process_is_primary, 1);
|
||||||
g_spdk_nvme_driver->initialized = false;
|
g_spdk_nvme_driver->initialized = false;
|
||||||
ut_destruct_called = false;
|
ut_destruct_called = false;
|
||||||
probe_ctx.cb_ctx = cb_ctx;
|
probe_ctx.cb_ctx = cb_ctx;
|
||||||
probe_ctx.attach_cb = attach_cb;
|
probe_ctx.attach_cb = attach_cb;
|
||||||
|
probe_ctx.trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
rc = nvme_init_controllers(&probe_ctx);
|
rc = nvme_init_controllers(&probe_ctx);
|
||||||
CU_ASSERT(rc != 0);
|
CU_ASSERT(rc != 0);
|
||||||
CU_ASSERT(g_spdk_nvme_driver->initialized == true);
|
CU_ASSERT(g_spdk_nvme_driver->initialized == true);
|
||||||
|
Loading…
Reference in New Issue
Block a user