From 3fc793591d050509f95b190587b0931059f57826 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Uchida Date: Mon, 23 May 2016 09:24:05 -0700 Subject: [PATCH] nvme/perf: Improve aio code Use O_WRONLY flag for write IO Cleanup io_context_t and io_event when perf exits Change-Id: Iefa1d8be5e017a1ca5719489c1ec4b868df94722 Signed-off-by: Daniel Verkamp --- examples/nvme/perf/perf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index a7f7ef50c..cd6b2f845 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -294,6 +294,8 @@ register_aio_file(const char *path) if (g_rw_percentage == 100) { flags = O_RDONLY; + } else if (g_rw_percentage == 0) { + flags = O_WRONLY; } else { flags = O_RDWR; } @@ -549,7 +551,12 @@ init_ns_worker_ctx(struct ns_worker_ctx *ns_ctx) static void cleanup_ns_worker_ctx(struct ns_worker_ctx *ns_ctx) { - if (ns_ctx->entry->type == ENTRY_TYPE_NVME_NS) { + if (ns_ctx->entry->type == ENTRY_TYPE_AIO_FILE) { +#ifdef HAVE_LIBAIO + io_destroy(ns_ctx->u.aio.ctx); + free(ns_ctx->u.aio.events); +#endif + } else { spdk_nvme_ctrlr_free_io_qpair(ns_ctx->u.nvme.qpair); } }