Commit 938d2ae2 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

test/nvme: Use spdk_nvme_detach_async() and spdk_nvme_detach_poll_async()



Use spdk_nvme_detach_async() and spdk_nvme_detach_poll_async() with
a local variable detach_ctx to detach multiple controllers.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I77cdc07ddfcd97569e31eeb245cd4e5a26289dbd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4441


Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 7a85c283
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -523,6 +523,7 @@ int main(int argc, char **argv)
	struct dev		*dev;
	struct spdk_env_opts	opts;
	int			rc;
	struct spdk_nvme_detach_ctx *detach_ctx = NULL;

	rc = parse_args(argc, argv);
	if (rc != 0) {
@@ -593,7 +594,11 @@ int main(int argc, char **argv)
	}

	foreach_dev(dev) {
		spdk_nvme_detach(dev->ctrlr);
		spdk_nvme_detach_async(dev->ctrlr, &detach_ctx);
	}

	while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
		;
	}

done:
+6 −1
Original line number Diff line number Diff line
@@ -607,6 +607,7 @@ int main(int argc, char **argv)
	struct dev		*iter;
	int			rc;
	struct spdk_env_opts	opts;
	struct spdk_nvme_detach_ctx *detach_ctx = NULL;

	spdk_env_opts_init(&opts);
	opts.name = "nvme_dp";
@@ -643,7 +644,11 @@ int main(int argc, char **argv)
	printf("Cleaning up...\n");

	foreach_dev(iter) {
		spdk_nvme_detach(iter->ctrlr);
		spdk_nvme_detach_async(iter->ctrlr, &detach_ctx);
	}

	while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
		;
	}

	return rc;
+5 −1
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ int main(int argc, char **argv)
	struct dev		*dev;
	struct spdk_env_opts	opts;
	int			rc;
	struct spdk_nvme_detach_ctx *detach_ctx = NULL;

	spdk_env_opts_init(&opts);
	opts.name = "err_injection";
@@ -270,7 +271,10 @@ int main(int argc, char **argv)
exit:
	printf("Cleaning up...\n");
	foreach_dev(dev) {
		spdk_nvme_detach(dev->ctrlr);
		spdk_nvme_detach_async(dev->ctrlr, &detach_ctx);
	}
	while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
		;
	}

	return failed;
+6 −1
Original line number Diff line number Diff line
@@ -645,6 +645,7 @@ cleanup(void)
{
	struct ns_entry *ns_entry = g_ns;
	struct ctrlr_entry *ctrlr_entry, *tmp_ctrlr_entry;
	struct spdk_nvme_detach_ctx *detach_ctx = NULL;

	while (ns_entry) {
		struct ns_entry *next = ns_entry->next;
@@ -657,9 +658,13 @@ cleanup(void)

	TAILQ_FOREACH_SAFE(ctrlr_entry, &g_ctrlr, link, tmp_ctrlr_entry) {
		TAILQ_REMOVE(&g_ctrlr, ctrlr_entry, link);
		spdk_nvme_detach(ctrlr_entry->ctrlr);
		spdk_nvme_detach_async(ctrlr_entry->ctrlr, &detach_ctx);
		free(ctrlr_entry);
	}

	while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
		;
	}
}

int main(int argc, char **argv)
+6 −1
Original line number Diff line number Diff line
@@ -414,6 +414,7 @@ int main(int argc, char **argv)
	struct dev		*iter;
	struct spdk_env_opts	opts;
	int			ret = 0;
	struct spdk_nvme_detach_ctx *detach_ctx = NULL;

	spdk_env_opts_init(&opts);
	opts.name = "reserve";
@@ -448,7 +449,11 @@ int main(int argc, char **argv)
	printf("Reservation test %s\n", ret ? "failed" : "passed");

	foreach_dev(iter) {
		spdk_nvme_detach(iter->ctrlr);
		spdk_nvme_detach_async(iter->ctrlr, &detach_ctx);
	}

	while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
		;
	}

	return ret;
Loading