Commit 59746336 authored by Changpeng Liu's avatar Changpeng Liu
Browse files

nvme: return error if the controller with probe context got errors



Change-Id: I72b2ab93d15a82c20d90e787248248b15bc197c7
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447021


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 9e378073
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -612,12 +612,13 @@ struct spdk_nvme_probe_ctx *spdk_nvme_probe_async(const struct spdk_nvme_transpo
 *
 * \param probe_ctx Context used to track probe actions.
 *
 * \return true if all probe operations are complete; the probe_ctx
 * \return 0 if all probe operations are complete; the probe_ctx
 * is also freed and no longer valid.
 * \return false if there are still pending probe operations; user must call
 * \return -EAGAIN if there are still pending probe operations; user must call
 * spdk_nvme_probe_poll_async again to continue progress.
 * \return value other than 0 and -EAGAIN probe error with one controller.
 */
bool spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx);
int 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
+12 −6
Original line number Diff line number Diff line
@@ -1092,28 +1092,34 @@ spdk_nvme_probe_async(const struct spdk_nvme_transport_id *trid,
	return probe_ctx;
}

bool
int
spdk_nvme_probe_poll_async(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) {
		free(probe_ctx);
		return true;
		return 0;
	}

	TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) {
		nvme_ctrlr_poll_internal(ctrlr, probe_ctx);
		rc = nvme_ctrlr_poll_internal(ctrlr, probe_ctx);
		if (rc != 0) {
			rc = -EIO;
			break;
		}
	}

	if (TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) {
	if (rc != 0 || 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);
		free(probe_ctx);
		return true;
		return rc;
	}
	return false;

	return -EAGAIN;
}

SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)