diff --git a/examples/nvme/abort/abort.c b/examples/nvme/abort/abort.c index 1a73b38b7..6309053a9 100644 --- a/examples/nvme/abort/abort.c +++ b/examples/nvme/abort/abort.c @@ -904,12 +904,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/examples/nvme/arbitration/arbitration.c b/examples/nvme/arbitration/arbitration.c index d94bf801e..6308b9e61 100644 --- a/examples/nvme/arbitration/arbitration.c +++ b/examples/nvme/arbitration/arbitration.c @@ -867,6 +867,7 @@ 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); @@ -874,9 +875,13 @@ unregister_controllers(void) spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) { set_latency_tracking_feature(entry->ctrlr, false); } - 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/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index 8d0a605b8..e87b5d302 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -1006,13 +1006,18 @@ static void spdk_fio_cleanup(struct thread_data *td) g_td_count--; if (g_td_count == 0) { struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp; + struct spdk_nvme_detach_ctx *detach_ctx = NULL; TAILQ_FOREACH_SAFE(fio_ctrlr, &g_ctrlrs, link, fio_ctrlr_tmp) { TAILQ_REMOVE(&g_ctrlrs, fio_ctrlr, link); - spdk_nvme_detach(fio_ctrlr->ctrlr); + spdk_nvme_detach_async(fio_ctrlr->ctrlr, &detach_ctx); free(fio_ctrlr); } + while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) { + ; + } + if (fio_options->enable_vmd) { spdk_vmd_fini(); } diff --git a/examples/nvme/hello_world/hello_world.c b/examples/nvme/hello_world/hello_world.c index d11b3b1dc..cfd440656 100644 --- a/examples/nvme/hello_world/hello_world.c +++ b/examples/nvme/hello_world/hello_world.c @@ -372,6 +372,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); @@ -380,9 +381,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 diff --git a/examples/nvme/nvme_manage/nvme_manage.c b/examples/nvme/nvme_manage/nvme_manage.c index 894f356b6..310c1e29c 100644 --- a/examples/nvme/nvme_manage/nvme_manage.c +++ b/examples/nvme/nvme_manage/nvme_manage.c @@ -1616,6 +1616,7 @@ int main(int argc, char **argv) int rc; struct spdk_env_opts opts; struct dev *dev; + struct spdk_nvme_detach_ctx *detach_ctx = NULL; rc = parse_args(argc, argv); if (rc != 0) { @@ -1696,7 +1697,11 @@ int main(int argc, char **argv) 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 0; diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 7b619960d..5ca7709fd 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -2168,6 +2168,7 @@ 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); @@ -2188,10 +2189,14 @@ unregister_controllers(void) free(entry->unused_qpairs); } - 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) { + ; + } + if (g_vmd) { spdk_vmd_fini(); } diff --git a/examples/nvme/reconnect/reconnect.c b/examples/nvme/reconnect/reconnect.c index 1387b74e7..9f8f9bee7 100644 --- a/examples/nvme/reconnect/reconnect.c +++ b/examples/nvme/reconnect/reconnect.c @@ -955,12 +955,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