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:
parent
4325814761
commit
dba5490000
@ -61,7 +61,7 @@ struct spdk_fio_ctrlr {
|
|||||||
|
|
||||||
struct spdk_fio_ctrlr *ctrlr_g;
|
struct spdk_fio_ctrlr *ctrlr_g;
|
||||||
int td_count;
|
int td_count;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
struct spdk_fio_qpair {
|
struct spdk_fio_qpair {
|
||||||
struct fio_file *f;
|
struct fio_file *f;
|
||||||
@ -216,6 +216,8 @@ static int spdk_fio_setup(struct thread_data *td)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
fio_thread = calloc(1, sizeof(*fio_thread));
|
fio_thread = calloc(1, sizeof(*fio_thread));
|
||||||
assert(fio_thread != NULL);
|
assert(fio_thread != NULL);
|
||||||
|
|
||||||
@ -233,7 +235,6 @@ static int spdk_fio_setup(struct thread_data *td)
|
|||||||
spdk_env_init(&opts);
|
spdk_env_init(&opts);
|
||||||
spdk_env_initialized = true;
|
spdk_env_initialized = true;
|
||||||
cpu_core_unaffinitized();
|
cpu_core_unaffinitized();
|
||||||
pthread_mutex_init(&mutex, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_file(td, f, i) {
|
for_each_file(td, f, i) {
|
||||||
@ -292,6 +293,8 @@ static int spdk_fio_setup(struct thread_data *td)
|
|||||||
|
|
||||||
td_count++;
|
td_count++;
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user