Fio 1.53
[fio.git] / init.c
diff --git a/init.c b/init.c
index 2ae93a026f2aad21025ea3eae8bfc1491646062b..63826662f2fbba0e7fd902c01399afad2202f0a9 100644 (file)
--- a/init.c
+++ b/init.c
@@ -22,7 +22,7 @@
 
 #include "lib/getopt.h"
 
-static char fio_version_string[] = "fio 1.51";
+static char fio_version_string[] = "fio 1.53";
 
 #define FIO_RANDSEED           (0xb1899bedUL)
 
@@ -191,7 +191,7 @@ static void put_job(struct thread_data *td)
 {
        if (td == &def_thread)
                return;
-       
+
        profile_td_exit(td);
 
        if (td->error)
@@ -463,7 +463,7 @@ static int exists_and_not_file(const char *filename)
        return 1;
 }
 
-void td_fill_rand_seeds(struct thread_data *td)
+static void td_fill_rand_seeds_os(struct thread_data *td)
 {
        os_random_seed(td->rand_seeds[0], &td->bsrange_state);
        os_random_seed(td->rand_seeds[1], &td->verify_state);
@@ -482,9 +482,37 @@ void td_fill_rand_seeds(struct thread_data *td)
                td->rand_seeds[4] = FIO_RANDSEED * td->thread_number;
 
        os_random_seed(td->rand_seeds[4], &td->random_state);
+}
+
+static void td_fill_rand_seeds_internal(struct thread_data *td)
+{
+       init_rand_seed(&td->__bsrange_state, td->rand_seeds[0]);
+       init_rand_seed(&td->__verify_state, td->rand_seeds[1]);
+       init_rand_seed(&td->__rwmix_state, td->rand_seeds[2]);
+
+       if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
+               init_rand_seed(&td->__next_file_state, td->rand_seeds[3]);
+
+       init_rand_seed(&td->__file_size_state, td->rand_seeds[5]);
+       init_rand_seed(&td->__trim_state, td->rand_seeds[6]);
+
+       if (!td_random(td))
+               return;
+
+       if (td->o.rand_repeatable)
+               td->rand_seeds[4] = FIO_RANDSEED * td->thread_number;
+
        init_rand_seed(&td->__random_state, td->rand_seeds[4]);
 }
 
+void td_fill_rand_seeds(struct thread_data *td)
+{
+       if (td->o.use_os_rand)
+               td_fill_rand_seeds_os(td);
+       else
+               td_fill_rand_seeds_internal(td);
+}
+
 /*
  * Initialize the various random states we need (random io, block size ranges,
  * read/write mix, etc).
@@ -807,7 +835,7 @@ static int parse_jobs_ini(char *file, int stonewall_flag)
 
                if (is_empty_or_comment(p))
                        continue;
-               if (sscanf(p, "[%255s]", name) != 1) {
+               if (sscanf(p, "[%255[^\n]]", name) != 1) {
                        if (inside_skip)
                                continue;
                        log_err("fio: option <%s> outside of [] job section\n",