Merge branch 'master' of ssh://brick.kernel.dk/data/git/fio
authorJens Axboe <jens.axboe@oracle.com>
Tue, 7 Apr 2009 20:21:28 +0000 (22:21 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 7 Apr 2009 20:21:28 +0000 (22:21 +0200)
engines/libaio.c
fio.c
fio.h
init.c
io_u.c

index 4f1e0ed4b739a3a62cad6322342bf285f75d2190..e452f1ca7c55f630c18c49186ece3f091713d0db 100644 (file)
@@ -64,11 +64,11 @@ static int fio_libaio_getevents(struct thread_data *td, unsigned int min,
                                unsigned int max, struct timespec *t)
 {
        struct libaio_data *ld = td->io_ops->data;
-       long r;
+       int r;
 
        do {
                r = io_getevents(ld->aio_ctx, min, max, ld->aio_events, t);
-               if (r >= min)
+               if (r >= (int) min)
                        break;
                else if (r == -EAGAIN) {
                        usleep(100);
diff --git a/fio.c b/fio.c
index f699951dcf58697f87922be056bfe99191e82f96..ad2282d7516fe7fc0033b3bc721a12b16d370fe1 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -876,6 +876,11 @@ static void reset_io_counters(struct thread_data *td)
         */
        if (td->o.time_based || td->o.loops)
                td->nr_done_files = 0;
+
+       /*
+        * Set the same seed to get repeatable runs
+        */
+       td_fill_rand_seeds(td);
 }
 
 void reset_all_stats(struct thread_data *td)
diff --git a/fio.h b/fio.h
index a9e2e3bb6443f9e224da6653e338fd80f3d36241..ff0068ca17290450307602f6b44585cab71b3e36 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -572,6 +572,8 @@ struct thread_data {
 
        char *sysfs_root;
 
+       unsigned long rand_seeds[6];
+
        os_random_state_t bsrange_state;
        os_random_state_t verify_state;
 
@@ -854,6 +856,7 @@ extern int fio_show_option_help(const char *);
 extern void fio_options_dup_and_init(struct option *);
 extern void options_mem_dupe(struct thread_data *);
 extern void options_mem_free(struct thread_data *);
+extern void td_fill_rand_seeds(struct thread_data *);
 #define FIO_GETOPT_JOB         0x89988998
 #define FIO_NR_OPTIONS         128
 
@@ -1033,6 +1036,8 @@ static inline void fio_file_reset(struct fio_file *f)
 {
        f->last_free_lookup = 0;
        f->last_pos = f->file_offset;
+       if (f->file_map)
+               memset(f->file_map, 0, f->num_maps * sizeof(int));
 }
 
 static inline void clear_error(struct thread_data *td)
diff --git a/init.c b/init.c
index 80d098dd9159a6d926a8c53113946522c10d0084..b2cfeab33925c9184ebeef07513fcb97126049d1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -19,7 +19,7 @@
 #include "smalloc.h"
 #include "filehash.h"
 
-static char fio_version_string[] = "fio 1.24";
+static char fio_version_string[] = "fio 1.25";
 
 #define FIO_RANDSEED           (0xb1899bedUL)
 
@@ -408,13 +408,32 @@ static int exists_and_not_file(const char *filename)
        return 1;
 }
 
+void td_fill_rand_seeds(struct thread_data *td)
+{
+       os_random_seed(td->rand_seeds[0], &td->bsrange_state);
+       os_random_seed(td->rand_seeds[1], &td->verify_state);
+       os_random_seed(td->rand_seeds[2], &td->rwmix_state);
+
+       if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
+               os_random_seed(td->rand_seeds[3], &td->next_file_state);
+
+       os_random_seed(td->rand_seeds[5], &td->file_size_state);
+
+       if (!td_random(td))
+               return;
+
+       if (td->o.rand_repeatable)
+               td->rand_seeds[4] = FIO_RANDSEED * td->thread_number;
+
+       os_random_seed(td->rand_seeds[4], &td->random_state);
+}
+
 /*
  * Initialize the various random states we need (random io, block size ranges,
  * read/write mix, etc).
  */
 static int init_random_state(struct thread_data *td)
 {
-       unsigned long seeds[6];
        int fd;
 
        fd = open("/dev/urandom", O_RDONLY);
@@ -423,30 +442,15 @@ static int init_random_state(struct thread_data *td)
                return 1;
        }
 
-       if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
+       if (read(fd, td->rand_seeds, sizeof(td->rand_seeds)) <
+           (int) sizeof(td->rand_seeds)) {
                td_verror(td, EIO, "read");
                close(fd);
                return 1;
        }
 
        close(fd);
-
-       os_random_seed(seeds[0], &td->bsrange_state);
-       os_random_seed(seeds[1], &td->verify_state);
-       os_random_seed(seeds[2], &td->rwmix_state);
-
-       if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
-               os_random_seed(seeds[3], &td->next_file_state);
-
-       os_random_seed(seeds[5], &td->file_size_state);
-
-       if (!td_random(td))
-               return 0;
-
-       if (td->o.rand_repeatable)
-               seeds[4] = FIO_RANDSEED * td->thread_number;
-
-       os_random_seed(seeds[4], &td->random_state);
+       td_fill_rand_seeds(td);
        return 0;
 }
 
diff --git a/io_u.c b/io_u.c
index 476658edfc9ee48baa2bab76846135dbcbc9b127..71089390a401e0899b1d7bdca9f8297f19dbfb32 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -748,23 +748,12 @@ static int set_io_u_file(struct thread_data *td, struct io_u *io_u)
                if (!f)
                        return 1;
 
-set_file:
                io_u->file = f;
                get_file(f);
 
                if (!fill_io_u(td, io_u))
                        break;
 
-               /*
-                * optimization to prevent close/open of the same file. This
-                * way we preserve queueing etc.
-                */
-               if (td->o.nr_files == 1 && td->o.time_based) {
-                       put_file_log(td, f);
-                       fio_file_reset(f);
-                       goto set_file;
-               }
-
                put_file_log(td, f);
                td_io_close_file(td, f);
                io_u->file = NULL;