From: Jens Axboe Date: Thu, 2 Nov 2017 15:04:56 +0000 (-0600) Subject: filesetup: change random file init to be bool based X-Git-Tag: fio-3.2~9 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=4d832322bf67a8a496bee049bc7dd9a2fdd828a2 filesetup: change random file init to be bool based Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index 6dbe59b2..d3e9bf81 100644 --- 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 90fb00a3..cc721ee2 100644 --- 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 *); diff --git a/filesetup.c b/filesetup.c index 2cc7158e..1efffa8f 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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)