X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=4750ac600a4272142bc85ccf9333382fcb1a4d28;hp=136dc04e7e22d881e1e07f32265ceebc9fbe4122;hb=d78ee463665c7eb710e5ee5070b7873bee6dc611;hpb=429f6675446eec26652b010b0c715d8bb6bc32e1 diff --git a/io_u.c b/io_u.c index 136dc04e..4750ac60 100644 --- a/io_u.c +++ b/io_u.c @@ -55,7 +55,7 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) * If we have a mixed random workload, we may * encounter blocks we already did IO to. */ - if (!td->o.ddir_nr && !random_map_free(td, f, block)) + if (!td->o.ddir_nr == 1 && !random_map_free(td, f, block)) break; idx = RAND_MAP_IDX(td, f, block); @@ -162,10 +162,11 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u) if (get_next_rand_offset(td, f, ddir, &b)) return 1; } else { - if (f->last_pos >= f->real_file_size) - return 1; - - b = f->last_pos / td->o.min_bs[ddir]; + if (f->last_pos >= f->real_file_size) { + if (!td_random(td) || get_next_rand_offset(td, f, ddir, &b)) + return 1; + } else + b = (f->last_pos - f->file_offset) / td->o.min_bs[ddir]; } io_u->offset = (b * td->o.min_bs[ddir]) + f->file_offset; @@ -190,6 +191,9 @@ static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u) buflen = (buflen + td->o.min_bs[ddir] - 1) & ~(td->o.min_bs[ddir] - 1); } + if (io_u->offset + buflen > io_u->file->real_file_size) + buflen = td->o.min_bs[ddir]; + return buflen; } @@ -341,6 +345,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) if (!io_u->buflen) return 1; + if (io_u->offset + io_u->buflen > io_u->file->real_file_size) + return 1; + /* * mark entry before potentially trimming io_u */