X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=d8f4f4cfb28e807ba98e2dc8735cc0609acd980e;hp=6d503606b10ebe7145c449b1d8c14390a4f99549;hb=34febb23fa9c7b9b0d54c324effff1a808a8fe6e;hpb=ecfd2bb08cc87bc9a1b3d612258f1fdfb4d09698 diff --git a/backend.c b/backend.c index 6d503606..d8f4f4cf 100644 --- a/backend.c +++ b/backend.c @@ -524,6 +524,9 @@ sync_done: break; } + if (td->flags & TD_F_REGROW_LOGS) + regrow_logs(td); + /* * when doing I/O (not when verifying), * check for any errors that are to be ignored @@ -1425,7 +1428,6 @@ static void *thread_main(void *data) struct thread_data *td = fd->td; struct thread_options *o = &td->o; struct sk_out *sk_out = fd->sk_out; - pthread_condattr_t attr; int clear_state; int ret; @@ -1450,12 +1452,18 @@ static void *thread_main(void *data) INIT_FLIST_HEAD(&td->verify_list); INIT_FLIST_HEAD(&td->trim_list); INIT_FLIST_HEAD(&td->next_rand_list); - pthread_mutex_init(&td->io_u_lock, NULL); td->io_hist_tree = RB_ROOT; - pthread_condattr_init(&attr); - pthread_cond_init(&td->verify_cond, &attr); - pthread_cond_init(&td->free_cond, &attr); + ret = mutex_cond_init_pshared(&td->io_u_lock, &td->free_cond); + if (ret) { + td_verror(td, ret, "mutex_cond_init_pshared"); + goto err; + } + ret = cond_init_pshared(&td->verify_cond); + if (ret) { + td_verror(td, ret, "mutex_cond_pshared"); + goto err; + } td_set_runstate(td, TD_INITIALIZED); dprint(FD_MUTEX, "up startup_mutex\n"); @@ -1791,39 +1799,6 @@ err: return (void *) (uintptr_t) td->error; } - -/* - * We cannot pass the td data into a forked process, so attach the td and - * pass it to the thread worker. - */ -static int fork_main(struct sk_out *sk_out, int shmid, int offset) -{ - struct fork_data *fd; - void *data, *ret; - -#if !defined(__hpux) && !defined(CONFIG_NO_SHM) - data = shmat(shmid, NULL, 0); - if (data == (void *) -1) { - int __err = errno; - - perror("shmat"); - return __err; - } -#else - /* - * HP-UX inherits shm mappings? - */ - data = threads; -#endif - - fd = calloc(1, sizeof(*fd)); - fd->td = data + offset * sizeof(struct thread_data); - fd->sk_out = sk_out; - ret = thread_main(fd); - shmdt(data); - return (int) (uintptr_t) ret; -} - static void dump_td_info(struct thread_data *td) { log_err("fio: job '%s' (state=%d) hasn't exited in %lu seconds, it " @@ -2161,6 +2136,7 @@ reap: struct thread_data *map[REAL_MAX_JOBS]; struct timeval this_start; int this_jobs = 0, left; + struct fork_data *fd; /* * create threads (TD_NOT_CREATED -> TD_CREATED) @@ -2210,14 +2186,13 @@ reap: map[this_jobs++] = td; nr_started++; + fd = calloc(1, sizeof(*fd)); + fd->td = td; + fd->sk_out = sk_out; + if (td->o.use_thread) { - struct fork_data *fd; int ret; - fd = calloc(1, sizeof(*fd)); - fd->td = td; - fd->sk_out = sk_out; - dprint(FD_PROCESS, "will pthread_create\n"); ret = pthread_create(&td->thread, NULL, thread_main, fd); @@ -2237,8 +2212,9 @@ reap: dprint(FD_PROCESS, "will fork\n"); pid = fork(); if (!pid) { - int ret = fork_main(sk_out, shm_id, i); + int ret; + ret = (int)(uintptr_t)thread_main(fd); _exit(ret); } else if (i == fio_debug_jobno) *fio_debug_jobp = pid;