X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=dcb56f1a5a854b1cb5e0c924ffa67072cd8adee0;hp=b049b61853fdfbd305ad01d857046be88dc68671;hb=1e5324e723116a5faf9da686993cc79c14d62d4b;hpb=4d2987c3e47aaffcc88a9255316323cf94d7e029 diff --git a/io_u.c b/io_u.c index b049b618..dcb56f1a 100644 --- a/io_u.c +++ b/io_u.c @@ -78,7 +78,7 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) mask = -1UL; else mask = ((1UL << this_blocks) - 1) << bit; - + if (!(f->file_map[idx] & mask)) break; @@ -157,8 +157,8 @@ static int get_next_free_block(struct thread_data *td, struct fio_file *f, return 1; } -static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, - enum fio_ddir ddir, unsigned long long *b) +static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f, + enum fio_ddir ddir, unsigned long long *b) { unsigned long long rmax, r, lastb; int loops = 5; @@ -234,6 +234,36 @@ ret: return 0; } +static int __get_next_rand_offset_zipf(struct thread_data *td, + struct fio_file *f, enum fio_ddir ddir, + unsigned long long *b) +{ + *b = zipf_next(&f->zipf); + return 0; +} + +static int __get_next_rand_offset_pareto(struct thread_data *td, + struct fio_file *f, enum fio_ddir ddir, + unsigned long long *b) +{ + *b = pareto_next(&f->zipf); + return 0; +} + +static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, + enum fio_ddir ddir, unsigned long long *b) +{ + if (td->o.random_distribution == FIO_RAND_DIST_RANDOM) + return __get_next_rand_offset(td, f, ddir, b); + else if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) + return __get_next_rand_offset_zipf(td, f, ddir, b); + else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) + return __get_next_rand_offset_pareto(td, f, ddir, b); + + log_err("fio: unknown random distribution: %d\n", td->o.random_distribution); + return 1; +} + static int get_next_rand_block(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir, unsigned long long *b) { @@ -310,7 +340,7 @@ static int get_next_block(struct thread_data *td, struct io_u *io_u, ret = 1; } } - + if (!ret) { if (offset != -1ULL) io_u->offset = offset; @@ -383,7 +413,7 @@ static inline int io_u_fits(struct thread_data *td, struct io_u *io_u, static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u) { const int ddir = io_u->ddir; - unsigned int uninitialized_var(buflen); + unsigned int buflen = 0; unsigned int minbs, maxbs; unsigned long r, rand_max; @@ -1315,7 +1345,7 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, struct io_completion_data *icd, const enum fio_ddir idx, unsigned int bytes) { - unsigned long uninitialized_var(lusec); + unsigned long lusec = 0; if (!td->o.disable_clat || !td->o.disable_bw) lusec = utime_since(&io_u->issue_time, &icd->time); @@ -1329,8 +1359,8 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, if (td->o.max_latency && tusec > td->o.max_latency) { if (!td->error) log_err("fio: latency of %lu usec exceeds specified max (%u usec)\n", tusec, td->o.max_latency); - td_verror(td, ETIME, "max latency exceeded"); - icd->error = ETIME; + td_verror(td, ETIMEDOUT, "max latency exceeded"); + icd->error = ETIMEDOUT; } } @@ -1358,11 +1388,6 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir) static void io_completed(struct thread_data *td, struct io_u *io_u, struct io_completion_data *icd) { - /* - * Older gcc's are too dumb to realize that usec is always used - * initialized, silence that warning. - */ - unsigned long uninitialized_var(usec); struct fio_file *f; dprint_io_u(io_u, "io complete");