diff --git a/test/nvme/aer/aer.c b/test/nvme/aer/aer.c index be77a2e1a..7212d3a47 100644 --- a/test/nvme/aer/aer.c +++ b/test/nvme/aer/aer.c @@ -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: diff --git a/test/nvme/e2edp/nvme_dp.c b/test/nvme/e2edp/nvme_dp.c index 5e8590d9b..e256a0144 100644 --- a/test/nvme/e2edp/nvme_dp.c +++ b/test/nvme/e2edp/nvme_dp.c @@ -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; diff --git a/test/nvme/err_injection/err_injection.c b/test/nvme/err_injection/err_injection.c index 5f2faded1..dcd553d4a 100644 --- a/test/nvme/err_injection/err_injection.c +++ b/test/nvme/err_injection/err_injection.c @@ -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; diff --git a/test/nvme/overhead/overhead.c b/test/nvme/overhead/overhead.c index 20d833775..87527741c 100644 --- a/test/nvme/overhead/overhead.c +++ b/test/nvme/overhead/overhead.c @@ -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) diff --git a/test/nvme/reserve/reserve.c b/test/nvme/reserve/reserve.c index bb0b2ede5..23f81fc4d 100644 --- a/test/nvme/reserve/reserve.c +++ b/test/nvme/reserve/reserve.c @@ -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; diff --git a/test/nvme/reset/reset.c b/test/nvme/reset/reset.c index 595b6eec3..597443d0e 100644 --- a/test/nvme/reset/reset.c +++ b/test/nvme/reset/reset.c @@ -553,12 +553,17 @@ static void unregister_controllers(void) { struct ctrlr_entry *entry, *tmp; + struct spdk_nvme_detach_ctx *detach_ctx = NULL; TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) { TAILQ_REMOVE(&g_controllers, entry, link); - spdk_nvme_detach(entry->ctrlr); + spdk_nvme_detach_async(entry->ctrlr, &detach_ctx); free(entry); } + + while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) { + ; + } } static int diff --git a/test/nvme/sgl/sgl.c b/test/nvme/sgl/sgl.c index bb3cf9f55..a699b69ca 100644 --- a/test/nvme/sgl/sgl.c +++ b/test/nvme/sgl/sgl.c @@ -495,6 +495,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_sgl"; @@ -536,7 +537,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; diff --git a/test/nvme/startup/startup.c b/test/nvme/startup/startup.c index e77655e17..9579624f9 100644 --- a/test/nvme/startup/startup.c +++ b/test/nvme/startup/startup.c @@ -100,6 +100,7 @@ cleanup(void) { struct ns_entry *ns_entry, *tmp_ns_entry; struct ctrlr_entry *ctrlr_entry, *tmp_ctrlr_entry; + struct spdk_nvme_detach_ctx *detach_ctx = NULL; TAILQ_FOREACH_SAFE(ns_entry, &g_namespaces, link, tmp_ns_entry) { TAILQ_REMOVE(&g_namespaces, ns_entry, link); @@ -108,9 +109,13 @@ cleanup(void) TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp_ctrlr_entry) { TAILQ_REMOVE(&g_controllers, 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) { + ; + } } static void