summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-11-02 08:59:07 -0600
committerJens Axboe <axboe@kernel.dk>2017-11-02 08:59:07 -0600
commitc139f3b446083d12d981f426cdbb105947b30b5c (patch)
tree8ab4090558e6452c11b89ce3e3780d1e50da9433
parentc75f74fb4dce30811d5b4ed09f884c97972828f1 (diff)
filesetup: pre_read_files() can use a bool
This flips the success return from 0 to true. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--backend.c6
-rw-r--r--file.h2
-rw-r--r--filesetup.c23
3 files changed, 15 insertions, 16 deletions
diff --git a/backend.c b/backend.c
index c14f37c..6dbe59b 100644
--- a/backend.c
+++ b/backend.c
@@ -1698,10 +1698,8 @@ static void *thread_main(void *data)
if (o->exec_prerun && exec_string(o, o->exec_prerun, (const char *)"prerun"))
goto err;
- if (o->pre_read) {
- if (pre_read_files(td) < 0)
- goto err;
- }
+ if (o->pre_read && !pre_read_files(td))
+ goto err;
fio_verify_init(td);
diff --git a/file.h b/file.h
index e3864ee..90fb00a 100644
--- a/file.h
+++ b/file.h
@@ -198,7 +198,7 @@ extern int __must_check generic_get_file_size(struct thread_data *, struct fio_f
}
#endif
extern int __must_check file_lookup_open(struct fio_file *f, int flags);
-extern int __must_check pre_read_files(struct thread_data *);
+extern bool __must_check pre_read_files(struct thread_data *);
extern unsigned long long get_rand_file_size(struct thread_data *td);
extern int add_file(struct thread_data *, const char *, int, int);
extern int add_file_exclusive(struct thread_data *, const char *);
diff --git a/filesetup.c b/filesetup.c
index e7abac1..0437a77 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -255,24 +255,25 @@ err:
return 1;
}
-static int pre_read_file(struct thread_data *td, struct fio_file *f)
+static bool pre_read_file(struct thread_data *td, struct fio_file *f)
{
- int ret = 0, r, did_open = 0, old_runstate;
+ int r, did_open = 0, old_runstate;
unsigned long long left;
unsigned int bs;
+ bool ret = true;
char *b;
if (td_ioengine_flagged(td, FIO_PIPEIO) ||
td_ioengine_flagged(td, FIO_NOIO))
- return 0;
+ return true;
if (f->filetype == FIO_TYPE_CHAR)
- return 0;
+ return true;
if (!fio_file_open(f)) {
if (td->io_ops->open_file(td, f)) {
log_err("fio: cannot pre-read, failed to open file\n");
- return 1;
+ return false;
}
did_open = 1;
}
@@ -287,7 +288,7 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
b = malloc(bs);
if (!b) {
td_verror(td, errno, "malloc");
- ret = 1;
+ ret = false;
goto error;
}
memset(b, 0, bs);
@@ -295,7 +296,7 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
td_verror(td, errno, "lseek");
log_err("fio: failed to lseek pre-read file\n");
- ret = 1;
+ ret = false;
goto error;
}
@@ -1174,7 +1175,7 @@ err_out:
return 1;
}
-int pre_read_files(struct thread_data *td)
+bool pre_read_files(struct thread_data *td)
{
struct fio_file *f;
unsigned int i;
@@ -1182,11 +1183,11 @@ int pre_read_files(struct thread_data *td)
dprint(FD_FILE, "pre_read files\n");
for_each_file(td, f, i) {
- if (pre_read_file(td, f))
- return -1;
+ if (!pre_read_file(td, f))
+ return false;
}
- return 0;
+ return true;
}
static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)