Better check for not doing a file twice
authorJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 18:34:47 +0000 (20:34 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 18:34:47 +0000 (20:34 +0200)
Mark it as done when we close it, so we don't open the same
one again.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.h
io_u.c

diff --git a/fio.h b/fio.h
index 76d7ea46747d264f6c28cd9474e4fa3a5e41f32f..5ca72c59d5c707b80a326df4011b012b31e688be 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -240,6 +240,7 @@ enum fio_file_flags {
        FIO_FILE_EXISTS         = 1 << 3,       /* file there */
        FIO_FILE_EXTEND         = 1 << 4,       /* needs extend */
        FIO_FILE_NOSORT         = 1 << 5,       /* don't sort verify blocks */
        FIO_FILE_EXISTS         = 1 << 3,       /* file there */
        FIO_FILE_EXTEND         = 1 << 4,       /* needs extend */
        FIO_FILE_NOSORT         = 1 << 5,       /* don't sort verify blocks */
+       FIO_FILE_DONE           = 1 << 6,       /* io completed to this file */
 };
 
 /*
 };
 
 /*
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];
 
                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;
 
                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 (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;
 
                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);
                 */
                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
 
                /*
                 * probably not the right place to do this, but see