From 89519ebc495fc25efcc57647fcd94661bb709535 Mon Sep 17 00:00:00 2001 From: Jin Yu Date: Tue, 24 Mar 2020 00:53:18 +0800 Subject: [PATCH] fio: make the ctrlr send keep alive in time In spdk_fio_setup when the connections are too many, for example 16 subsystems, it would take too much time to complete the probe. And it takes the mutex that makes the poll_ctrlr function can't send the keep alive cmd which causes the target timeout. Split the mutex so the poll_ctrlr has the chance to sent keep alive. Fixes issue: #1286 Change-Id: I300513b5e8761d9eaadb4c5cbc8ed97fe84d02df Signed-off-by: Jin Yu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1407 Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- examples/nvme/fio_plugin/fio_plugin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index 3d720018f..7301a68ae 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -240,6 +240,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, } ns_id = (uint32_t)tmp; + pthread_mutex_lock(&g_mutex); fio_ctrlr = get_fio_ctrlr(trid); /* it is a new ctrlr and needs to be added */ if (!fio_ctrlr) { @@ -248,6 +249,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, if (!fio_ctrlr) { SPDK_ERRLOG("Cannot allocate space for fio_ctrlr\n"); g_error = true; + pthread_mutex_unlock(&g_mutex); return; } fio_ctrlr->opts = *opts; @@ -256,6 +258,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, fio_ctrlr->next = g_ctrlr; g_ctrlr = fio_ctrlr; } + pthread_mutex_unlock(&g_mutex); ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id); if (ns == NULL) { @@ -436,6 +439,7 @@ static int spdk_fio_setup(struct thread_data *td) SPDK_ERRLOG("Failed to initialize VMD. Some NVMe devices can be unavailable.\n"); } } + pthread_mutex_unlock(&g_mutex); for_each_file(td, f, i) { memset(&trid, 0, sizeof(trid)); @@ -478,7 +482,9 @@ static int spdk_fio_setup(struct thread_data *td) fio_thread->current_f = f; + pthread_mutex_lock(&g_mutex); fio_ctrlr = get_fio_ctrlr(&trid); + pthread_mutex_unlock(&g_mutex); if (fio_ctrlr) { attach_cb(td, &trid, fio_ctrlr->ctrlr, &fio_ctrlr->opts); } else { @@ -496,8 +502,8 @@ static int spdk_fio_setup(struct thread_data *td) } } + pthread_mutex_lock(&g_mutex); g_td_count++; - pthread_mutex_unlock(&g_mutex); return rc;