Signed-off-by: Jens Axboe <axboe@fb.com>
static void *helper_thread_main(void *data)
{
static void *helper_thread_main(void *data)
{
+ struct backend_data *d = data;
+ if (d)
+ pthread_setspecific(d->key, d->ptr);
+
fio_mutex_up(startup_mutex);
while (!ret) {
fio_mutex_up(startup_mutex);
while (!ret) {
-static int create_helper_thread(void)
+static int create_helper_thread(struct backend_data *data)
pthread_cond_init(&helper_cond, NULL);
pthread_mutex_init(&helper_lock, NULL);
pthread_cond_init(&helper_cond, NULL);
pthread_mutex_init(&helper_lock, NULL);
- ret = pthread_create(&helper_thread, NULL, helper_thread_main, NULL);
+ ret = pthread_create(&helper_thread, NULL, helper_thread_main, data);
if (ret) {
log_err("Can't create helper thread: %s\n", strerror(ret));
return 1;
if (ret) {
log_err("Can't create helper thread: %s\n", strerror(ret));
return 1;
+int fio_backend(struct backend_data *data)
{
struct thread_data *td;
int i;
{
struct thread_data *td;
int i;
set_genesis_time();
stat_init();
set_genesis_time();
stat_init();
- create_helper_thread();
+ create_helper_thread(data);
cgroup_list = smalloc(sizeof(*cgroup_list));
INIT_FLIST_HEAD(cgroup_list);
cgroup_list = smalloc(sizeof(*cgroup_list));
INIT_FLIST_HEAD(cgroup_list);
goto done;
ret = fio_handle_clients(&fio_client_ops);
} else
goto done;
ret = fio_handle_clients(&fio_client_ops);
} else
+ ret = fio_backend(NULL);
done:
deinitialize_fio();
done:
deinitialize_fio();
RATE_PROCESS_POISSON = 1,
};
RATE_PROCESS_POISSON = 1,
};
+/*
+ * Per-thread/process specific data. Only used for the network client
+ * for now.
+ */
+struct backend_data {
+ pthread_key_t key;
+ void *ptr;
+};
+
/*
* This describes a single thread/process executing a fio job.
*/
/*
* This describes a single thread/process executing a fio job.
*/
extern int __must_check parse_options(int, char **);
extern int parse_jobs_ini(char *, int, int, int);
extern int parse_cmd_line(int, char **, int);
extern int __must_check parse_options(int, char **);
extern int parse_jobs_ini(char *, int, int, int);
extern int parse_cmd_line(int, char **, int);
-extern int fio_backend(void);
+extern int fio_backend(struct backend_data *);
extern void reset_fio_state(void);
extern void clear_io_state(struct thread_data *, int);
extern int fio_options_parse(struct thread_data *, char **, int, int);
extern void reset_fio_state(void);
extern void clear_io_state(struct thread_data *, int);
extern int fio_options_parse(struct thread_data *, char **, int, int);
+ ret = fio_backend(NULL);
free_threads_shm();
_exit(ret);
}
free_threads_shm();
_exit(ret);
}