Commit 5a26346a authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/444492


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 97768b07
Loading
Loading
Loading
Loading
+24 −27
Original line number Diff line number Diff line
@@ -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;
	return nvme_init_controllers(&probe_ctx);
}

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_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;
	}
	}

	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;

	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) {
		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 true;
}

SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
+2 −0
Original line number Diff line number Diff line
@@ -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);