Better check for not doing a file twice
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index f71856fc8b943b08fcc0835f3c91eeacd790b6bb..5f51a00e2457e4880468c8dc2b21ce4da93a39b3 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -422,6 +422,8 @@ static struct fio_file *get_next_file_rand(struct thread_data *td, int goodf,
 
                fno = (unsigned int) ((double) td->o.nr_files * (r / (RAND_MAX + 1.0)));
                f = &td->files[fno];
+               if (f->flags & FIO_FILE_DONE)
+                       continue;
 
                if ((!goodf || (f->flags & goodf)) && !(f->flags & badf))
                        return f;
@@ -444,6 +446,9 @@ static struct fio_file *get_next_file_rr(struct thread_data *td, int goodf,
                if (td->next_file >= td->o.nr_files)
                        td->next_file = 0;
 
+               if (f->flags & FIO_FILE_DONE)
+                       continue;
+
                if ((!goodf || (f->flags & goodf)) && !(f->flags & badf))
                        break;
 
@@ -554,6 +559,7 @@ set_file:
                 */
                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