Always exit if do_exit is set after parse
[fio.git] / init.c
diff --git a/init.c b/init.c
index b330925c0067e856d3e9ddbda94d42013139bf45..c44fa671aa9a3851da57270dd4b901ec272223be 100644 (file)
--- a/init.c
+++ b/init.c
@@ -621,6 +621,14 @@ static int fixup_options(struct thread_data *td)
        if (td->o.random_distribution != FIO_RAND_DIST_RANDOM)
                td->o.norandommap = 1;
 
+       /*
+        * If size is set but less than the min block size, complain
+        */
+       if (o->size && o->size < td_min_bs(td)) {
+               log_err("fio: size too small, must be larger than the IO size: %llu\n", (unsigned long long) o->size);
+               ret = 1;
+       }
+
        return ret;
 }
 
@@ -693,6 +701,7 @@ static void td_fill_rand_seeds_os(struct thread_data *td)
                td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number;
 
        os_random_seed(td->rand_seeds[FIO_RAND_BLOCK_OFF], &td->random_state);
+       os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_OFF], &td->seq_rand_state);
 }
 
 static void td_fill_rand_seeds_internal(struct thread_data *td)
@@ -714,6 +723,7 @@ static void td_fill_rand_seeds_internal(struct thread_data *td)
                td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number;
 
        init_rand_seed(&td->__random_state, td->rand_seeds[FIO_RAND_BLOCK_OFF]);
+       init_rand_seed(&td->__seq_rand_state, td->rand_seeds[FIO_RAND_SEQ_RAND_OFF]);
 }
 
 void td_fill_rand_seeds(struct thread_data *td)
@@ -1715,9 +1725,20 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                                fio_options_set_ioengine_opts(l_opts, td);
                        }
 
-                       ret = fio_cmd_option_parse(td, opt, val);
-                       if (ret)
+                       if ((!val || !strlen(val)) &&
+                           l_opts[lidx].has_arg == required_argument) {
+                               log_err("fio: option %s requires an argument\n", opt);
+                               ret = 1;
+                       } else
+                               ret = fio_cmd_option_parse(td, opt, val);
+
+                       if (ret) {
+                               if (td) {
+                                       put_job(td);
+                                       td = NULL;
+                               }
                                do_exit++;
+                       }
 
                        if (!ret && !strcmp(opt, "ioengine")) {
                                free_ioengine(td);
@@ -1823,10 +1844,8 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        break;
        }
 
-       if (do_exit) {
-               if (exit_val && !(is_backend || nr_clients))
-                       exit(exit_val);
-       }
+       if (do_exit && !(is_backend || nr_clients))
+               exit(exit_val);
 
        if (nr_clients && fio_clients_connect()) {
                do_exit++;