- do {
- f = get_next_file(td);
- if (!f) {
- put_io_u(td, io_u);
- return NULL;
- }
-
-set_file:
- io_u->file = f;
-
- if (!fill_io_u(td, io_u))
- break;
-
- /*
- * No more to do for this file, close it
- */
- io_u->file = NULL;
- td_io_close_file(td, f);
- f->flags |= FIO_FILE_DONE;
-
- /*
- * probably not the right place to do this, but see
- * if we need to open a new file
- */
- if (td->nr_open_files < td->o.open_files &&
- td->o.open_files != td->o.nr_files) {
- f = find_next_new_file(td);
-
- if (!f || (ret = td_io_open_file(td, f))) {
- put_io_u(td, io_u);
- return NULL;
- }
- goto set_file;
- }
- } while (1);
-
- if (td->zone_bytes >= td->o.zone_size) {
- td->zone_bytes = 0;
- f->last_pos += td->o.zone_skip;
- }
-
- if (io_u->buflen + io_u->offset > f->real_file_size) {
- if (td->io_ops->flags & FIO_RAWIO) {
- put_io_u(td, io_u);
- return NULL;
- }
-
- io_u->buflen = f->real_file_size - io_u->offset;
+ /*
+ * If using an iolog, grab next piece if any available.
+ */
+ if (td->o.read_iolog_file) {
+ if (read_iolog_get(td, io_u))
+ goto err_put;
+ } else if (set_io_u_file(td, io_u)) {
+ dprint(FD_IO, "io_u %p, setting file failed\n", io_u);
+ goto err_put;