X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=c9a20a3b36a188e01df2b5865f8e68140b28028f;hp=b9c1c1230585cc41b2a78eb8e218ebe58e6d87ea;hb=ce35b1ece06ce27ebff111e47c2a6610c311a92b;hpb=ce4864950d2ced54e0a1ccb8ef9a1e62135f1d2d diff --git a/backend.c b/backend.c index b9c1c123..c9a20a3b 100644 --- a/backend.c +++ b/backend.c @@ -642,12 +642,15 @@ static uint64_t do_io(struct thread_data *td) uint64_t bytes_done[DDIR_RWDIR_CNT] = { 0, 0, 0 }; unsigned int i; int ret = 0; + uint64_t bytes_issued = 0; if (in_ramp_time(td)) td_set_runstate(td, TD_RAMP); else td_set_runstate(td, TD_RUNNING); + lat_target_init(td); + while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) || (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) || td->o.time_based) { @@ -675,9 +678,15 @@ static uint64_t do_io(struct thread_data *td) if (flow_threshold_exceeded(td)) continue; + if (bytes_issued >= (uint64_t) td->o.size) + break; + io_u = get_io_u(td); - if (!io_u) + if (!io_u) { + if (td->o.latency_target) + goto reap; break; + } ddir = io_u->ddir; @@ -708,6 +717,7 @@ static uint64_t do_io(struct thread_data *td) int bytes = io_u->xfer_buflen - io_u->resid; struct fio_file *f = io_u->file; + bytes_issued += bytes; /* * zero read, fail */ @@ -738,6 +748,7 @@ sync_done: ret = io_u_sync_complete(td, io_u, bytes_done); if (ret < 0) break; + bytes_issued += io_u->xfer_buflen; } break; case FIO_Q_QUEUED: @@ -748,6 +759,7 @@ sync_done: */ if (td->io_ops->commit == NULL) io_u_queued(td, io_u); + bytes_issued += io_u->xfer_buflen; break; case FIO_Q_BUSY: requeue_io_u(td, &io_u); @@ -769,6 +781,7 @@ sync_done: * can get BUSY even without IO queued, if the system is * resource starved. */ +reap: full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth); if (full || !td->o.iodepth_batch_complete) { min_evts = min(td->o.iodepth_batch_complete, @@ -805,6 +818,8 @@ sync_done: break; } } + if (!in_ramp_time(td) && td->o.latency_target) + lat_target_check(td); if (td->o.thinktime) { unsigned long long b; @@ -919,7 +934,8 @@ static int init_io_u(struct thread_data *td) * overflow later. this adjustment may be too much if we get * lucky and the allocator gives us an aligned address. */ - if (td->o.odirect || td->o.mem_align || (td->io_ops->flags & FIO_RAWIO)) + if (td->o.odirect || td->o.mem_align || td->o.oatomic || + (td->io_ops->flags & FIO_RAWIO)) td->orig_buffer_size += page_mask + td->o.mem_align; if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE) { @@ -937,7 +953,7 @@ static int init_io_u(struct thread_data *td) if (data_xfer && allocate_io_mem(td)) return 1; - if (td->o.odirect || td->o.mem_align || + if (td->o.odirect || td->o.mem_align || td->o.oatomic || (td->io_ops->flags & FIO_RAWIO)) p = PAGE_ALIGN(td->orig_buffer) + td->o.mem_align; else @@ -973,7 +989,7 @@ static int init_io_u(struct thread_data *td) * Fill the buffer with the pattern if we are * going to be doing writes. */ - fill_pattern(td, io_u->buf, max_bs, io_u, 0, 0); + fill_verify_pattern(td, io_u->buf, max_bs, io_u, 0, 0); } } @@ -1122,6 +1138,11 @@ static void *thread_main(void *data) } else td->pid = gettid(); + /* + * fio_time_init() may not have been called yet if running as a server + */ + fio_time_init(); + fio_local_clock_init(o->use_thread); dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid); @@ -1583,7 +1604,7 @@ static void run_threads(void) if (fio_gtod_offload && fio_start_gtod_thread()) return; - + fio_idle_prof_init(); set_sig_handlers();