Commit 4a73675d authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

nvme: Remove deprecated spdk_nvme_ctrlr_reset_async() and _reset_poll_async()



Change spdk_nvme_ctrlr_reset() to use spdk_nvme_ctrlr_disconnect(),
spdk_nvme_ctrlr_reconnect_async(), and
spdk_nvme_ctrlr_reconnect_poll_async().

Then remove the deprecated spdk_nvme_ctrlr_reset_async() and
spdk_nvme_ctrlr_reset_poll_async().

These changes simplify the following patches to make
spdk_nvme_ctrlr_disconnect() asynchronous.

Change-Id: Ia71e8e0ad5b2dff42b7423634f66de47863926e2
Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10913


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent cfe11bd1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -19,3 +19,8 @@ ABI cannot be removed without providing deprecation notice for at least single S
Deprecated `spdk_nvme_ctrlr_reset_async` and `spdk_nvme_ctrlr_reset_poll_async` APIs,
which will be removed in SPDK 22.01. `spdk_nvme_ctrlr_disconnect`, `spdk_nvme_ctrlr_reconnect_async`,
and `spdk_nvme_ctrlr_reconnect_poll_async` should be used instead.

### bdev

Deprecated `spdk_bdev_module_finish_done()` API, which will be removed in SPDK 22.01.
Bdev modules should use `spdk_bdev_module_fini_done()` instead.
+0 −40
Original line number Diff line number Diff line
@@ -1077,46 +1077,6 @@ int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr);
 */
void spdk_nvme_ctrlr_prepare_for_reset(struct spdk_nvme_ctrlr *ctrlr);

struct spdk_nvme_ctrlr_reset_ctx;

/**
 * Create a context object that can be polled to perform a full hardware reset of the NVMe controller.
 * (Deprecated, please use spdk_nvme_ctrlr_disconnect(), spdk_nvme_ctrlr_reconnect_async(), and
 * spdk_nvme_ctrlr_reconnect_poll_async() instead.)
 *
 * The function will set the controller reset context on success, user must call
 * spdk_nvme_ctrlr_reset_poll_async() until it returns a value other than -EAGAIN.
 *
 * \param ctrlr Opaque handle to NVMe controller.
 * \param reset_ctx Double pointer to reset context.
 *
 * \return 0 on success.
 * \return -ENOMEM if context could not be allocated.
 * \return -EBUSY if controller is already resetting.
 * \return -ENXIO if controller has been removed.
 *
 */
int spdk_nvme_ctrlr_reset_async(struct spdk_nvme_ctrlr *ctrlr,
				struct spdk_nvme_ctrlr_reset_ctx **reset_ctx);

/**
 * Proceed with resetting controller associated with the controller reset context.
 * (Deprecated, please use spdk_nvme_ctrlr_disconnect(), spdk_nvme_ctrlr_reconnect_async(), and
 * spdk_nvme_ctrlr_reconnect_poll_async() instead.)
 *
 * The controller reset context is one returned from a previous call to
 * spdk_nvme_ctrlr_reset_async().  Users must call this function on the
 * controller reset context until it returns a value other than -EAGAIN.
 *
 * \param ctrlr_reset_ctx Context used to track controller reset actions.
 *
 * \return 0 if all controller reset operations are complete; the ctrlr_reset_ctx
 * is also freed and no longer valid.
 * \return -EAGAIN if there are still pending controller reset operations; user must call
 * spdk_nvme_ctrlr_reset_poll_async again to continue progress.
 */
int spdk_nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx);

/**
 * Disconnect the given NVMe controller.
 *
+4 −72
Original line number Diff line number Diff line
@@ -1686,20 +1686,6 @@ spdk_nvme_ctrlr_reconnect_async(struct spdk_nvme_ctrlr *ctrlr)
	 */
}

static int
nvme_ctrlr_reset_pre(struct spdk_nvme_ctrlr *ctrlr)
{
	int rc;

	rc = spdk_nvme_ctrlr_disconnect(ctrlr);
	if (rc != 0) {
		return rc;
	}

	spdk_nvme_ctrlr_reconnect_async(ctrlr);
	return 0;
}

/**
 * This function will be called when the controller is being reinitialized.
 * Note: the ctrlr_lock must be held when calling this function.
@@ -1778,77 +1764,23 @@ spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr)
	return rc;
}

static void
nvme_ctrlr_reset_ctx_init(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx,
			  struct spdk_nvme_ctrlr *ctrlr)
{
	ctrlr_reset_ctx->ctrlr = ctrlr;
}

static int
nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx)
{
	struct spdk_nvme_ctrlr *ctrlr = ctrlr_reset_ctx->ctrlr;

	return spdk_nvme_ctrlr_reconnect_poll_async(ctrlr);
}

int
spdk_nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx)
{
	int rc;
	if (!ctrlr_reset_ctx) {
		return -EINVAL;
	}
	rc = nvme_ctrlr_reset_poll_async(ctrlr_reset_ctx);
	if (rc == -EAGAIN) {
		return rc;
	}

	free(ctrlr_reset_ctx);
	return rc;
}

int
spdk_nvme_ctrlr_reset_async(struct spdk_nvme_ctrlr *ctrlr,
			    struct spdk_nvme_ctrlr_reset_ctx **reset_ctx)
{
	struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx;
	int rc;

	ctrlr_reset_ctx = calloc(1, sizeof(*ctrlr_reset_ctx));
	if (!ctrlr_reset_ctx) {
		return -ENOMEM;
	}

	rc = nvme_ctrlr_reset_pre(ctrlr);
	if (rc != 0) {
		free(ctrlr_reset_ctx);
	} else {
		nvme_ctrlr_reset_ctx_init(ctrlr_reset_ctx, ctrlr);
		*reset_ctx = ctrlr_reset_ctx;
	}

	return rc;
}

int
spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr)
{
	struct spdk_nvme_ctrlr_reset_ctx reset_ctx = {};
	int rc;

	rc = nvme_ctrlr_reset_pre(ctrlr);
	rc = spdk_nvme_ctrlr_disconnect(ctrlr);
	if (rc != 0) {
		if (rc == -EBUSY) {
			rc = 0;
		}
		return rc;
	}
	nvme_ctrlr_reset_ctx_init(&reset_ctx, ctrlr);

	spdk_nvme_ctrlr_reconnect_async(ctrlr);

	while (true) {
		rc = nvme_ctrlr_reset_poll_async(&reset_ctx);
		rc = spdk_nvme_ctrlr_reconnect_poll_async(ctrlr);
		if (rc != -EAGAIN) {
			break;
		}
+0 −4
Original line number Diff line number Diff line
@@ -1044,10 +1044,6 @@ struct spdk_nvme_detach_ctx {
	TAILQ_HEAD(, nvme_ctrlr_detach_ctx)	head;
};

struct spdk_nvme_ctrlr_reset_ctx {
	struct spdk_nvme_ctrlr			*ctrlr;
};

struct nvme_driver {
	pthread_mutex_t			lock;