init: force fallocate_mode to none when fallocate is unsupported
[fio.git] / init.c
diff --git a/init.c b/init.c
index 1f1ceebf33a7d432ad29825a106c5759d0d9bcc8..52560ed34ab59a28ad6a1825068f58e75496bea0 100644 (file)
--- a/init.c
+++ b/init.c
@@ -781,6 +781,11 @@ static int fixup_options(struct thread_data *td)
                        o->unit_base = 8;
        }
 
+#if !defined(CONFIG_POSIX_FALLOCATE) && !defined(FIO_HAVE_NATIVE_FALLOCATE)
+       /* Platform doesn't support fallocate so force set it to none */
+       o->fallocate_mode = FIO_FALLOCATE_NONE;
+#endif
+
 #ifndef CONFIG_FDATASYNC
        if (o->fdatasync_blocks) {
                log_info("fio: this platform does not support fdatasync()"
@@ -921,6 +926,12 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)
 {
        int i;
 
+       /*
+        * trimwrite is special in that we need to generate the same
+        * offsets to get the "write after trim" effect. If we are
+        * using bssplit to set buffer length distributions, ensure that
+        * we seed the trim and write generators identically.
+        */
        if (td_trimwrite(td)) {
                init_rand_seed(&td->bsrange_state[DDIR_READ], td->rand_seeds[FIO_RAND_BS_OFF], use64);
                init_rand_seed(&td->bsrange_state[DDIR_WRITE], td->rand_seeds[FIO_RAND_BS1_OFF], use64);
@@ -994,16 +1005,24 @@ int ioengine_load(struct thread_data *td)
 {
        const char *engine;
 
-       /*
-        * Engine has already been loaded.
-        */
-       if (td->io_ops)
-               return 0;
        if (!td->o.ioengine) {
                log_err("fio: internal fault, no IO engine specified\n");
                return 1;
        }
 
+       if (td->io_ops) {
+               /* An engine is loaded, but the requested ioengine
+                * may have changed.
+                */
+               if (!strcmp(td->io_ops->name, td->o.ioengine)) {
+                       /* The right engine is already loaded */
+                       return 0;
+               }
+
+               /* Unload the old engine. */
+               free_ioengine(td);
+       }
+
        engine = get_engine_name(td->o.ioengine);
        td->io_ops = load_ioengine(td, engine);
        if (!td->io_ops) {
@@ -2524,7 +2543,6 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        }
 
                        if (!ret && !strcmp(opt, "ioengine")) {
-                               free_ioengine(td);
                                if (ioengine_load(td)) {
                                        put_job(td);
                                        td = NULL;