filesetup: change random file init to be bool based
authorJens Axboe <axboe@kernel.dk>
Thu, 2 Nov 2017 15:04:56 +0000 (09:04 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 2 Nov 2017 15:04:56 +0000 (09:04 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c
file.h
filesetup.c

index 6dbe59b250de15a9c7b2d53664e6e82dfcb90898..d3e9bf8160615b64ae714b47f4524403df272f44 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1692,7 +1692,7 @@ static void *thread_main(void *data)
        if (td_io_init(td))
                goto err;
 
-       if (init_random_map(td))
+       if (!init_random_map(td))
                goto err;
 
        if (o->exec_prerun && exec_string(o, o->exec_prerun, (const char *)"prerun"))
diff --git a/file.h b/file.h
index 90fb00a35930f6793153d6cd18ca7698a59b4779..cc721ee27a33c03e1ed1ff430170bbdec5b77432 100644 (file)
--- a/file.h
+++ b/file.h
@@ -209,7 +209,7 @@ extern void lock_file(struct thread_data *, struct fio_file *, enum fio_ddir);
 extern void unlock_file(struct thread_data *, struct fio_file *);
 extern void unlock_file_all(struct thread_data *, struct fio_file *);
 extern int add_dir_files(struct thread_data *, const char *);
-extern int init_random_map(struct thread_data *);
+extern bool init_random_map(struct thread_data *);
 extern void dup_files(struct thread_data *, struct thread_data *);
 extern int get_fileno(struct thread_data *, const char *);
 extern void free_release_files(struct thread_data *);
index 2cc7158ead7eb1a8cf16020106c5002aaee9b441..1efffa8febb19d1a7f19ccc3110212f05686b6dd 100644 (file)
@@ -1213,14 +1213,14 @@ static void __init_rand_distribution(struct thread_data *td, struct fio_file *f)
                gauss_init(&f->gauss, nranges, td->o.gauss_dev.u.f, seed);
 }
 
-static int init_rand_distribution(struct thread_data *td)
+static bool init_rand_distribution(struct thread_data *td)
 {
        struct fio_file *f;
        unsigned int i;
        int state;
 
        if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
-               return 0;
+               return false;
 
        state = td_bump_runstate(td, TD_SETTING_UP);
 
@@ -1228,8 +1228,7 @@ static int init_rand_distribution(struct thread_data *td)
                __init_rand_distribution(td, f);
 
        td_restore_runstate(td, state);
-
-       return 1;
+       return true;
 }
 
 /*
@@ -1269,16 +1268,16 @@ static int check_rand_gen_limits(struct thread_data *td, struct fio_file *f,
        return 0;
 }
 
-int init_random_map(struct thread_data *td)
+bool init_random_map(struct thread_data *td)
 {
        unsigned long long blocks;
        struct fio_file *f;
        unsigned int i;
 
        if (init_rand_distribution(td))
-               return 0;
+               return true;
        if (!td_random(td))
-               return 0;
+               return true;
 
        for_each_file(td, f, i) {
                uint64_t fsize = min(f->real_file_size, f->io_size);
@@ -1286,7 +1285,7 @@ int init_random_map(struct thread_data *td)
                blocks = fsize / (unsigned long long) td->o.rw_min_bs;
 
                if (check_rand_gen_limits(td, f, blocks))
-                       return 1;
+                       return false;
 
                if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
                        unsigned long seed;
@@ -1311,14 +1310,14 @@ int init_random_map(struct thread_data *td)
                                " a large number of jobs, try the 'norandommap'"
                                " option or set 'softrandommap'. Or give"
                                " a larger --alloc-size to fio.\n");
-                       return 1;
+                       return false;
                }
 
                log_info("fio: file %s failed allocating random map. Running "
                         "job without.\n", f->file_name);
        }
 
-       return 0;
+       return true;
 }
 
 void close_files(struct thread_data *td)