test/app: 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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I43428a41df2b6f26b62cf03990d35add9a3663d6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4440
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-10-16 08:57:12 +09:00 committed by Jim Harris
parent 0a903c91ac
commit 7a85c283d9
2 changed files with 12 additions and 2 deletions

View File

@ -537,12 +537,17 @@ static void
free_controllers(void) free_controllers(void)
{ {
struct nvme_fuzz_ctrlr *ctrlr, *tmp; struct nvme_fuzz_ctrlr *ctrlr, *tmp;
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
TAILQ_FOREACH_SAFE(ctrlr, &g_ctrlr_list, tailq, tmp) { TAILQ_FOREACH_SAFE(ctrlr, &g_ctrlr_list, tailq, tmp) {
TAILQ_REMOVE(&g_ctrlr_list, ctrlr, tailq); TAILQ_REMOVE(&g_ctrlr_list, ctrlr, tailq);
spdk_nvme_detach(ctrlr->ctrlr); spdk_nvme_detach_async(ctrlr->ctrlr, &detach_ctx);
free(ctrlr); free(ctrlr);
} }
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
;
}
} }
static void static void

View File

@ -52,12 +52,17 @@ static void
cleanup(void) cleanup(void)
{ {
struct ctrlr_entry *ctrlr_entry, *tmp; struct ctrlr_entry *ctrlr_entry, *tmp;
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp) { TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp) {
TAILQ_REMOVE(&g_controllers, ctrlr_entry, link); 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); free(ctrlr_entry);
} }
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
;
}
} }
static void static void