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 <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1407
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jin Yu 2020-03-24 00:53:18 +08:00 committed by Tomasz Zawadzki
parent ec42f1a81f
commit 89519ebc49

View File

@ -240,6 +240,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
} }
ns_id = (uint32_t)tmp; ns_id = (uint32_t)tmp;
pthread_mutex_lock(&g_mutex);
fio_ctrlr = get_fio_ctrlr(trid); fio_ctrlr = get_fio_ctrlr(trid);
/* it is a new ctrlr and needs to be added */ /* it is a new ctrlr and needs to be added */
if (!fio_ctrlr) { if (!fio_ctrlr) {
@ -248,6 +249,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
if (!fio_ctrlr) { if (!fio_ctrlr) {
SPDK_ERRLOG("Cannot allocate space for fio_ctrlr\n"); SPDK_ERRLOG("Cannot allocate space for fio_ctrlr\n");
g_error = true; g_error = true;
pthread_mutex_unlock(&g_mutex);
return; return;
} }
fio_ctrlr->opts = *opts; 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; fio_ctrlr->next = g_ctrlr;
g_ctrlr = fio_ctrlr; g_ctrlr = fio_ctrlr;
} }
pthread_mutex_unlock(&g_mutex);
ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id); ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id);
if (ns == NULL) { 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"); SPDK_ERRLOG("Failed to initialize VMD. Some NVMe devices can be unavailable.\n");
} }
} }
pthread_mutex_unlock(&g_mutex);
for_each_file(td, f, i) { for_each_file(td, f, i) {
memset(&trid, 0, sizeof(trid)); memset(&trid, 0, sizeof(trid));
@ -478,7 +482,9 @@ static int spdk_fio_setup(struct thread_data *td)
fio_thread->current_f = f; fio_thread->current_f = f;
pthread_mutex_lock(&g_mutex);
fio_ctrlr = get_fio_ctrlr(&trid); fio_ctrlr = get_fio_ctrlr(&trid);
pthread_mutex_unlock(&g_mutex);
if (fio_ctrlr) { if (fio_ctrlr) {
attach_cb(td, &trid, fio_ctrlr->ctrlr, &fio_ctrlr->opts); attach_cb(td, &trid, fio_ctrlr->ctrlr, &fio_ctrlr->opts);
} else { } else {
@ -496,8 +502,8 @@ static int spdk_fio_setup(struct thread_data *td)
} }
} }
pthread_mutex_lock(&g_mutex);
g_td_count++; g_td_count++;
pthread_mutex_unlock(&g_mutex); pthread_mutex_unlock(&g_mutex);
return rc; return rc;