+static struct fio_file *get_next_file(struct thread_data *td)
+{
+ struct fio_file *f;
+
+ assert(td->o.nr_files <= td->files_index);
+
+ if (!td->nr_open_files)
+ return NULL;
+
+ f = td->file_service_file;
+ if (f && (f->flags & FIO_FILE_OPEN) && td->file_service_left--)
+ return f;
+
+ if (td->o.file_service_type == FIO_FSERVICE_RR)
+ f = get_next_file_rr(td, FIO_FILE_OPEN, FIO_FILE_CLOSING);
+ else
+ f = get_next_file_rand(td, FIO_FILE_OPEN, FIO_FILE_CLOSING);
+
+ td->file_service_file = f;
+ td->file_service_left = td->file_service_nr - 1;
+ return f;
+}
+
+static struct fio_file *find_next_new_file(struct thread_data *td)
+{
+ struct fio_file *f;
+
+ if (td->o.file_service_type == FIO_FSERVICE_RR)
+ f = get_next_file_rr(td, 0, FIO_FILE_OPEN);
+ else
+ f = get_next_file_rand(td, 0, FIO_FILE_OPEN);
+
+ return f;
+}
+