X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=backend.c;h=7343286d53219b0c8d4e8a44ec586f1cd66ac6b8;hb=591e9e0653dd8f5d8464b2896434a01ab742a3b1;hp=821e978a98b0152b2e4c099c5af6eb6d8e0b1abc;hpb=2e1df07d1ea30e0304cc65370f3ed161a6f22cd4;p=fio.git diff --git a/backend.c b/backend.c index 821e978a..7343286d 100644 --- a/backend.c +++ b/backend.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -58,8 +59,16 @@ static volatile int fio_abort; struct io_log *agg_io_log[2]; +int groupid = 0; +unsigned int thread_number = 0; +unsigned int nr_process = 0; +unsigned int nr_thread = 0; +int shm_id = 0; +int temp_stall_ts; +unsigned long done_secs = 0; + #define PAGE_ALIGN(buf) \ - (char *) (((unsigned long) (buf) + page_mask) & ~page_mask) + (char *) (((uintptr_t) (buf) + page_mask) & ~page_mask) #define JOB_START_TIMEOUT (5 * 1000) @@ -285,6 +294,7 @@ requeue: return 0; } + static inline void __update_tv_cache(struct thread_data *td) { fio_gettime(&td->tv_cache, NULL); @@ -354,8 +364,6 @@ static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir, return 0; } - - /* * The main verify engine. Runs over the writes we previously submitted, * reads the blocks back in, and checks the crc/md5 of the data. @@ -401,6 +409,9 @@ static void do_verify(struct thread_data *td) } } + if (flow_threshold_exceeded(td)) + continue; + io_u = __get_io_u(td); if (!io_u) break; @@ -515,6 +526,20 @@ sync_done: dprint(FD_VERIFY, "exiting loop\n"); } +static int io_bytes_exceeded(struct thread_data *td) +{ + unsigned long long bytes; + + if (td_rw(td)) + bytes = td->this_io_bytes[0] + td->this_io_bytes[1]; + else if (td_write(td)) + bytes = td->this_io_bytes[1]; + else + bytes = td->this_io_bytes[0]; + + return bytes >= td->o.size; +} + /* * Main IO worker function. It retrieves io_u's to process and queues * and reaps them, checking for rate and errors along the way. @@ -529,9 +554,8 @@ static void do_io(struct thread_data *td) else td_set_runstate(td, TD_RUNNING); - while ( (td->o.read_iolog_file && !flist_empty(&td->io_log_list)) || - (!flist_empty(&td->trim_list)) || - ((td->this_io_bytes[0] + td->this_io_bytes[1]) < td->o.size) ) { + while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) || + (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) { struct timeval comp_time; unsigned long bytes_done[2] = { 0, 0 }; int min_evts = 0; @@ -552,6 +576,9 @@ static void do_io(struct thread_data *td) } } + if (flow_threshold_exceeded(td)) + continue; + io_u = get_io_u(td); if (!io_u) break; @@ -559,11 +586,12 @@ static void do_io(struct thread_data *td) ddir = io_u->ddir; /* - * Add verification end_io handler, if asked to verify - * a previously written file. + * Add verification end_io handler if: + * - Asked to verify (!td_rw(td)) + * - Or the io_u is from our verify list (mixed write/ver) */ if (td->o.verify != VERIFY_NONE && io_u->ddir == DDIR_READ && - !td_rw(td)) { + ((io_u->flags & IO_U_F_VER_LIST) || !td_rw(td))) { if (td->o.verify_async) io_u->end_io = verify_io_u_async; else @@ -748,12 +776,13 @@ static void cleanup_io_u(struct thread_data *td) static int init_io_u(struct thread_data *td) { struct io_u *io_u; - unsigned int max_bs; + unsigned int max_bs, min_write; int cl_align, i, max_units; char *p; max_units = td->o.iodepth; max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]); + min_write = td->o.min_bs[DDIR_WRITE]; td->orig_buffer_size = (unsigned long long) max_bs * (unsigned long long) max_units; @@ -802,7 +831,7 @@ static int init_io_u(struct thread_data *td) dprint(FD_MEM, "io_u %p, mem %p\n", io_u, io_u->buf); if (td_write(td)) - io_u_fill_buffer(td, io_u, max_bs); + io_u_fill_buffer(td, io_u, min_write, max_bs); if (td_write(td) && td->o.verify_pattern_bytes) { /* * Fill the buffer with the pattern if we are @@ -1012,7 +1041,8 @@ static void *thread_main(void *data) if (td->o.cgroup_weight && cgroup_setup(td, cgroup_list, &cgroup_mnt)) goto err; - if (nice(td->o.nice) == -1) { + errno = 0; + if (nice(td->o.nice) == -1 && errno != 0) { td_verror(td, errno, "nice"); goto err; } @@ -1171,7 +1201,7 @@ err: write_iolog_close(td); td_set_runstate(td, TD_EXITED); - return (void *) (unsigned long) td->error; + return (void *) (uintptr_t) td->error; } @@ -1202,7 +1232,7 @@ static int fork_main(int shmid, int offset) td = data + offset * sizeof(struct thread_data); ret = thread_main(td); shmdt(data); - return (int) (unsigned long) ret; + return (int) (uintptr_t) ret; } /* @@ -1302,8 +1332,6 @@ reaped: fio_terminate_threads(TERMINATE_ALL); } - - /* * Main function for kicking off and reaping jobs, as needed. */ @@ -1488,7 +1516,8 @@ static void run_threads(void) } if (left) { - log_err("fio: %d jobs failed to start\n", left); + log_err("fio: %d job%s failed to start\n", left, + left > 1 ? "s" : ""); for (i = 0; i < this_jobs; i++) { td = map[i]; if (!td) @@ -1579,7 +1608,6 @@ static int create_disk_util_thread(void) return 0; } - int fio_backend(void) { struct thread_data *td; @@ -1634,5 +1662,3 @@ int fio_backend(void) fio_mutex_remove(writeout_mutex); return exit_value; } - -