static volatile int startup_sem;
static volatile int fio_abort;
+static int exit_value;
struct io_log *agg_io_log[2];
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;
break;
memcpy(&s, &io_u->start_time, sizeof(s));
-
requeue:
ret = td_io_queue(td, io_u);
if (ret) {
io_u->xfer_buf += ret;
goto requeue;
} else {
- td_verror(td, io_u->error);
put_io_u(td, io_u);
break;
}
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;
}
/*
continue;
}
+ if (td->error)
+ exit_value++;
+
td_set_runstate(td, TD_REAPED);
if (td->use_thread) {
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;
* 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--;
}
if (fork())
fio_sem_down(&startup_sem);
else {
- fork_main(shm_id, i);
- exit(0);
+ int ret = fork_main(shm_id, i);
+
+ exit(ret);
}
}
}
}
}
- return 0;
+ return exit_value;
}