From f248a52522789296001ddabbb6a79414ab49065b Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 7 Sep 2020 20:59:23 +0300 Subject: [PATCH] fio: cap io_size=N% at 100%, update man page Passing io_size > 100% results in semi-infinite loop, anyway. Signed-off-by: Alexey Dobriyan (SK hynix) Signed-off-by: Jens Axboe --- fio.1 | 3 ++- options.c | 6 +++++- parse.h | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fio.1 b/fio.1 index f15194ff..33240738 100644 --- a/fio.1 +++ b/fio.1 @@ -1561,7 +1561,8 @@ if \fBsize\fR is set to 20GiB and \fBio_size\fR is set to 5GiB, fio will perform I/O within the first 20GiB but exit when 5GiB have been done. The opposite is also possible \-\- if \fBsize\fR is set to 20GiB, and \fBio_size\fR is set to 40GiB, then fio will do 40GiB of I/O within -the 0..20GiB region. +the 0..20GiB region. Value can be set as percentage: \fBio_size\fR=N%. +In this case \fBio_size\fR multiplies \fBsize\fR= value. .TP .BI filesize \fR=\fPirange(int) Individual file sizes. May be a range, in which case fio will select sizes diff --git a/options.c b/options.c index e27bb9cb..852fb05b 100644 --- a/options.c +++ b/options.c @@ -1481,9 +1481,13 @@ static int str_io_size_cb(void *data, unsigned long long *__val) struct thread_data *td = cb_data_to_td(data); unsigned long long v = *__val; - if (parse_is_percent(v)) { + if (parse_is_percent_uncapped(v)) { td->o.io_size = 0; td->o.io_size_percent = -1ULL - v; + if (td->o.io_size_percent > 100) { + log_err("fio: io_size values greater than 100%% aren't supported\n"); + return 1; + } dprint(FD_PARSE, "SET io_size_percent %d\n", td->o.io_size_percent); } else diff --git a/parse.h b/parse.h index 5828654f..1d2cbf74 100644 --- a/parse.h +++ b/parse.h @@ -133,6 +133,11 @@ static inline int parse_is_percent(unsigned long long val) return val <= -1ULL && val >= (-1ULL - 100ULL); } +static inline int parse_is_percent_uncapped(unsigned long long val) +{ + return (long long)val <= -1; +} + struct print_option { struct flist_head list; char *name; -- 2.25.1