X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=8f0cdff718e70267c5a330b7aba9f439c09847ca;hp=10fa188dd9aa0eb6d7900cc6c6a151cafb337eba;hb=4981d2de251698ebbe78451bfe4615e0d09a5296;hpb=1c17818009ced8e78e9fee47fd9aaef29e708b41 diff --git a/io_u.c b/io_u.c index 10fa188d..8f0cdff7 100644 --- a/io_u.c +++ b/io_u.c @@ -109,6 +109,9 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u) unsigned long long max_blocks = f->file_size / td->min_bs[ddir]; int loops = 5; + if (!max_blocks) + return 1; + do { r = os_random_long(&td->random_state); b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0)); @@ -478,13 +481,13 @@ set_file: * probably not the right place to do this, but see * if we need to open a new file */ - if (td->nr_open_files < td->nr_files && + if (td->nr_open_files < td->open_files && td->open_files != td->nr_files) { f = find_next_new_file(td); if (!f || (ret = td_io_open_file(td, f))) { put_io_u(td, io_u); - break; + return NULL; } goto set_file; }