X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=b10e83eee3b3871aa3ad7a957e3cc0ffec00ea00;hp=06fb3cef80c7fb71c1c6aad29e1936b27e1b9b19;hb=04c540d9504fa81608952d6e2ce6b47066d2566c;hpb=5973cafb37fbf24c3ca2cdf86a3d03f1b00d6d2b diff --git a/io_u.c b/io_u.c index 06fb3cef..b10e83ee 100644 --- a/io_u.c +++ b/io_u.c @@ -79,8 +79,16 @@ static inline unsigned long long last_block(struct thread_data *td, enum fio_ddir ddir) { unsigned long long max_blocks; + unsigned long long max_size; - max_blocks = f->io_size / (unsigned long long) td->o.min_bs[ddir]; + /* + * Hmm, should we make sure that ->io_size <= ->real_file_size? + */ + max_size = f->io_size; + if (max_size > f->real_file_size) + max_size = f->real_file_size; + + max_blocks = max_size / (unsigned long long) td->o.min_bs[ddir]; if (!max_blocks) return 0; @@ -209,7 +217,7 @@ static int get_next_offset(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 buflen; + unsigned int buflen = buflen; /* silence dumb gcc warning */ long r; if (td->o.min_bs[ddir] == td->o.max_bs[ddir]) @@ -250,7 +258,6 @@ static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u) static void set_rwmix_bytes(struct thread_data *td) { - unsigned long issues; unsigned int diff; /* @@ -258,11 +265,8 @@ static void set_rwmix_bytes(struct thread_data *td) * buffered writes may issue a lot quicker than they complete, * whereas reads do not. */ - issues = td->io_issues[td->rwmix_ddir] - td->rwmix_issues; diff = td->o.rwmix[td->rwmix_ddir ^ 1]; - - td->rwmix_issues = td->io_issues[td->rwmix_ddir] - + (issues * ((100 - diff)) / diff); + td->rwmix_issues = (td->io_issues[td->rwmix_ddir] * diff) / 100; } static inline enum fio_ddir get_rand_ddir(struct thread_data *td) @@ -272,7 +276,7 @@ static inline enum fio_ddir get_rand_ddir(struct thread_data *td) r = os_random_long(&td->rwmix_state); v = 1 + (int) (100.0 * (r / (RAND_MAX + 1.0))); - if (v < td->o.rwmix[DDIR_READ]) + if (v <= td->o.rwmix[DDIR_READ]) return DDIR_READ; return DDIR_WRITE; @@ -422,6 +426,47 @@ out: return 0; } +static void __io_u_mark_map(unsigned int *map, unsigned int nr) +{ + int index = 0; + + switch (nr) { + default: + index = 6; + break; + case 33 ... 64: + index = 5; + break; + case 17 ... 32: + index = 4; + break; + case 9 ... 16: + index = 3; + break; + case 5 ... 8: + index = 2; + break; + case 1 ... 4: + index = 1; + case 0: + break; + } + + map[index]++; +} + +void io_u_mark_submit(struct thread_data *td, unsigned int nr) +{ + __io_u_mark_map(td->ts.io_u_submit, nr); + td->ts.total_submit++; +} + +void io_u_mark_complete(struct thread_data *td, unsigned int nr) +{ + __io_u_mark_map(td->ts.io_u_complete, nr); + td->ts.total_complete++; +} + void io_u_mark_depth(struct thread_data *td, unsigned int nr) { int index = 0;