From: Jens Axboe Date: Thu, 2 Nov 2017 14:59:07 +0000 (-0600) Subject: filesetup: pre_read_files() can use a bool X-Git-Tag: fio-3.2~11 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c139f3b446083d12d981f426cdbb105947b30b5c filesetup: pre_read_files() can use a bool This flips the success return from 0 to true. Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index c14f37ca..6dbe59b2 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 e3864ee5..90fb00a3 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 e7abac14..0437a776 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)