X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio.c;h=e386f53c0259726cabfb388909d0e85c6e6a8a49;hp=9c970333bb4090644fb32fec4ef9010a45214628;hb=a64181472b3556b6e7b95443d94869f6b61ca7ad;hpb=dbe1125e9c53b2a0b1fc2fd9c6cfd0b3fbddda8b diff --git a/fio.c b/fio.c index 9c970333..e386f53c 100644 --- a/fio.c +++ b/fio.c @@ -47,6 +47,7 @@ int temp_stall_ts; static volatile int startup_sem; static volatile int fio_abort; +static int exit_value; struct io_log *agg_io_log[2]; @@ -382,7 +383,7 @@ static void do_io(struct thread_data *td) td_set_runstate(td, TD_RUNNING); - while (td->this_io_bytes[td->ddir] < td->io_size) { + while ((td->this_io_bytes[0] + td->this_io_bytes[1]) < td->io_size) { struct timespec *timeout; int min_evts = 0; struct io_u *io_u; @@ -399,7 +400,6 @@ static void do_io(struct thread_data *td) break; memcpy(&s, &io_u->start_time, sizeof(s)); - requeue: ret = td_io_queue(td, io_u); if (ret) { @@ -412,7 +412,6 @@ requeue: io_u->xfer_buf += ret; goto requeue; } else { - td_verror(td, io_u->error); put_io_u(td, io_u); break; } @@ -756,33 +755,36 @@ static void *thread_main(void *data) terminate_threads(td->groupid, 0); err: + if (td->error) + printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror); close_files(td); close_ioengine(td); cleanup_io_u(td); td_set_runstate(td, TD_EXITED); - return NULL; - + return (void *) td->error; } /* * We cannot pass the td data into a forked process, so attach the td and * pass it to the thread worker. */ -static void *fork_main(int shmid, int offset) +static int fork_main(int shmid, int offset) { struct thread_data *td; - void *data; + void *data, *ret; data = shmat(shmid, NULL, 0); if (data == (void *) -1) { + int __err = errno; + perror("shmat"); - return NULL; + return __err; } td = data + offset * sizeof(struct thread_data); - thread_main(td); + ret = thread_main(td); shmdt(data); - return NULL; + return (int) ret; } /* @@ -812,6 +814,9 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate) continue; } + if (td->error) + exit_value++; + td_set_runstate(td, TD_REAPED); if (td->use_thread) { @@ -819,8 +824,15 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate) if (pthread_join(td->thread, (void *) &ret)) perror("thread_join"); - } else - waitpid(td->pid, NULL, 0); + } else { + int status; + + waitpid(td->pid, &status, 0); + if (WIFEXITED(status) && WEXITSTATUS(status)) { + if (!exit_value) + exit_value++; + } + } (*nr_running)--; (*m_rate) -= td->ratemin; @@ -870,6 +882,9 @@ static void run_threads(void) * client data interspersed on disk */ if (setup_files(td)) { + exit_value++; + if (td->error) + log_err("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror); td_set_runstate(td, TD_REAPED); todo--; } @@ -926,8 +941,9 @@ static void run_threads(void) if (fork()) fio_sem_down(&startup_sem); else { - fork_main(shm_id, i); - exit(0); + int ret = fork_main(shm_id, i); + + exit(ret); } } } @@ -1046,5 +1062,5 @@ int main(int argc, char *argv[]) } } - return 0; + return exit_value; }