X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio.c;h=fcd15286a95b971692b5ca65af9de34e2bfd5662;hp=0ec4f5a0e347f975078cb9628e5c81641ad592f4;hb=51b6996ea57913166a7cd5d777d1c1647a65731b;hpb=1f809d151ddc4a4c348c2e4f6007db510e3e08a2 diff --git a/fio.c b/fio.c index 0ec4f5a0..fcd15286 100644 --- a/fio.c +++ b/fio.c @@ -60,6 +60,8 @@ struct io_log *agg_io_log[2]; static inline void td_set_runstate(struct thread_data *td, int runstate) { + dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", td->pid, td->runstate, + runstate); td->runstate = runstate; } @@ -70,6 +72,7 @@ static void terminate_threads(int group_id) for_each_td(td, i) { if (group_id == TERMINATE_ALL || groupid == td->groupid) { + dprint(FD_PROCESS, "setting terminate on %d\n",td->pid); /* * if the thread is running, just let it exit */ @@ -568,6 +571,10 @@ sync_done: } } + if (td->o.fill_device && td->error == ENOSPC) { + td->error = 0; + td->terminate = 1; + } if (!td->error) { struct fio_file *f; @@ -586,6 +593,12 @@ sync_done: } } else cleanup_pending_aio(td); + + /* + * stop job if we failed doing any IO + */ + if ((td->this_io_bytes[0] + td->this_io_bytes[1]) == 0) + td->done = 1; } static void cleanup_io_u(struct thread_data *td) @@ -626,11 +639,7 @@ static int init_io_u(struct thread_data *td) int i, max_units; char *p; - if (td->io_ops->flags & FIO_SYNCIO) - max_units = 1; - else - max_units = td->o.iodepth; - + max_units = td->o.iodepth; max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]); td->orig_buffer_size = (unsigned long long) max_bs * (unsigned long long) max_units; @@ -657,10 +666,12 @@ static int init_io_u(struct thread_data *td) memset(io_u, 0, sizeof(*io_u)); INIT_LIST_HEAD(&io_u->list); - io_u->buf = p + max_bs * i; + if (!(td->io_ops->flags & FIO_NOIO)) { + io_u->buf = p + max_bs * i; - if (td_write(td)) - fill_io_buf(td, io_u, max_bs); + if (td_write(td)) + fill_io_buf(td, io_u, max_bs); + } io_u->index = i; io_u->flags = IO_U_F_FREE; @@ -762,7 +773,10 @@ static int clear_io_state(struct thread_data *td) td->last_was_sync = 0; - if (td->o.time_based) + /* + * reset file done count if we are to start over + */ + if (td->o.time_based || td->o.loops) td->nr_done_files = 0; for_each_file(td, f, i) @@ -785,9 +799,8 @@ static int clear_io_state(struct thread_data *td) */ static void *thread_main(void *data) { - unsigned long long runtime[2]; + unsigned long long runtime[2], elapsed; struct thread_data *td = data; - unsigned long elapsed; int clear_state; if (!td->o.use_thread) @@ -795,6 +808,8 @@ static void *thread_main(void *data) td->pid = getpid(); + dprint(FD_PROCESS, "jobs pid=%d started\n", td->pid); + INIT_LIST_HEAD(&td->io_u_freelist); INIT_LIST_HEAD(&td->io_u_busylist); INIT_LIST_HEAD(&td->io_u_requeues); @@ -827,7 +842,7 @@ static void *thread_main(void *data) goto err; } - if (td->ioprio) { + if (td->ioprio_set) { if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) { td_verror(td, errno, "ioprio_set"); goto err; @@ -1057,8 +1072,11 @@ reaped: if (td->o.use_thread) { long ret; - if (pthread_join(td->thread, (void *) &ret)) + dprint(FD_PROCESS, "joining tread %d\n", td->pid); + if (pthread_join(td->thread, (void *) &ret)) { + dprint(FD_PROCESS, "join failed %ld\n", ret); perror("pthread_join"); + } } (*nr_running)--; @@ -1173,12 +1191,14 @@ static void run_threads(void) nr_started++; if (td->o.use_thread) { + dprint(FD_PROCESS, "will pthread_create\n"); if (pthread_create(&td->thread, NULL, thread_main, td)) { perror("thread_create"); nr_started--; break; } } else { + dprint(FD_PROCESS, "will fork\n"); if (!fork()) { int ret = fork_main(shm_id, i);