summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-11-02 09:04:56 -0600
committerJens Axboe <axboe@kernel.dk>2017-11-02 09:04:56 -0600
commit4d832322bf67a8a496bee049bc7dd9a2fdd828a2 (patch)
tree46be143430cc1a3095e662019f486050e1baea40
parent3a03f0cf8005221d90045bed762e7d5e38f944fb (diff)
filesetup: change random file init to be bool based
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--backend.c2
-rw-r--r--file.h2
-rw-r--r--filesetup.c19
3 files changed, 11 insertions, 12 deletions
diff --git a/backend.c b/backend.c
index 6dbe59b..d3e9bf8 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 90fb00a..cc721ee 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 2cc7158..1efffa8 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)