From d07dc4d361575d857ab533ab957ead7fd4c49032 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 14 Dec 2021 15:49:02 +0000 Subject: [PATCH] nvme/fio: free io_qpairs in close callback If user uses the 'loops' parameter, then it will call the open+close callbacks for each loop, but only cleanup at the end of the entire run. Since we alloc the io_qpair in open, but don't free them until cleanup, we end up running out of io qpairs at some point if we run too many loops. So solution is to free the io qpairs in the close callback. Signed-off-by: Jim Harris Change-Id: Ibac864836f94994cdd24a7886894778268b14f73 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10674 Reviewed-by: Ben Walker Reviewed-by: John Kariuki Reviewed-by: Changpeng Liu Reviewed-by: Dong Yi Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- examples/nvme/fio_plugin/fio_plugin.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index 55b4bc4c4..db3b31686 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -711,6 +711,7 @@ static int spdk_fio_open(struct thread_data *td, struct fio_file *f) struct spdk_fio_options *fio_options = td->eo; struct spdk_nvme_io_qpair_opts qpopts; + assert(fio_qpair->qpair == NULL); spdk_nvme_ctrlr_get_default_io_qpair_opts(fio_ctrlr->ctrlr, &qpopts, sizeof(qpopts)); qpopts.delay_cmd_submit = true; if (fio_options->enable_wrr) { @@ -735,6 +736,11 @@ static int spdk_fio_open(struct thread_data *td, struct fio_file *f) static int spdk_fio_close(struct thread_data *td, struct fio_file *f) { + struct spdk_fio_qpair *fio_qpair = f->engine_data; + + assert(fio_qpair->qpair != NULL); + spdk_nvme_ctrlr_free_io_qpair(fio_qpair->qpair); + fio_qpair->qpair = NULL; return 0; } @@ -1426,7 +1432,6 @@ static void spdk_fio_cleanup(struct thread_data *td) TAILQ_FOREACH_SAFE(fio_qpair, &fio_thread->fio_qpair, link, fio_qpair_tmp) { TAILQ_REMOVE(&fio_thread->fio_qpair, fio_qpair, link); - spdk_nvme_ctrlr_free_io_qpair(fio_qpair->qpair); free(fio_qpair); }