From 00833e651c68a99bb6ba3658f7fdb292bbebd0b2 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 22 Jun 2021 17:29:28 +0900 Subject: [PATCH] example/nvme_identify: Use spdk_nvme_detach_async() Signed-off-by: Shuhei Matsumoto Change-Id: Ie026026fd64d36974e4a877aa9755bafdbe4fb29 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8473 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- examples/nvme/identify/identify.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 8da8f5fc9..6e7294e97 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -111,6 +111,8 @@ static bool g_vmd = false; static bool g_ocssd_verbose = false; +static struct spdk_nvme_detach_ctx *g_detach_ctx = NULL; + static void hex_dump(const void *data, size_t size) { @@ -2205,7 +2207,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, { g_controllers_found++; print_controller(ctrlr, trid); - spdk_nvme_detach(ctrlr); + spdk_nvme_detach_async(ctrlr, &g_detach_ctx); } int main(int argc, char **argv) @@ -2254,12 +2256,16 @@ int main(int argc, char **argv) g_controllers_found++; print_controller(ctrlr, &g_trid); - spdk_nvme_detach(ctrlr); + spdk_nvme_detach_async(ctrlr, &g_detach_ctx); } else if (spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } + if (g_detach_ctx) { + spdk_nvme_detach_poll(g_detach_ctx); + } + if (g_controllers_found == 0) { fprintf(stderr, "No NVMe controllers found.\n"); }