nvme/fio_plugin: make setup callback thread safe

Change-Id: I40f858a204bf0ca5e594fc8efcb1a31849e6709b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-05-10 16:07:33 -07:00 committed by Jim Harris
parent 4325814761
commit dba5490000

View File

@ -61,7 +61,7 @@ struct spdk_fio_ctrlr {
struct spdk_fio_ctrlr *ctrlr_g;
int td_count;
pthread_mutex_t mutex;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
struct spdk_fio_qpair {
struct fio_file *f;
@ -216,6 +216,8 @@ static int spdk_fio_setup(struct thread_data *td)
return 1;
}
pthread_mutex_lock(&mutex);
fio_thread = calloc(1, sizeof(*fio_thread));
assert(fio_thread != NULL);
@ -233,7 +235,6 @@ static int spdk_fio_setup(struct thread_data *td)
spdk_env_init(&opts);
spdk_env_initialized = true;
cpu_core_unaffinitized();
pthread_mutex_init(&mutex, NULL);
}
for_each_file(td, f, i) {
@ -292,6 +293,8 @@ static int spdk_fio_setup(struct thread_data *td)
td_count++;
pthread_mutex_unlock(&mutex);
return 0;
}