fio: cap io_size=N% at 100%, update man page
authorAlexey Dobriyan <adobriyan@gmail.com>
Mon, 7 Sep 2020 17:59:23 +0000 (20:59 +0300)
committerJens Axboe <axboe@kernel.dk>
Mon, 7 Sep 2020 19:34:51 +0000 (13:34 -0600)
Passing io_size > 100% results in semi-infinite loop, anyway.

Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.1
options.c
parse.h

diff --git a/fio.1 b/fio.1
index f15194ff78c464913c6cf7cc1e110f5817b0d2de..33240738a7846a0493573cd8275d414cc5e5da07 100644 (file)
--- 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
index e27bb9cb724fce1b0227a67567a4a22acac0f3d3..852fb05bec44111613907a18bf7433c83b29698a 100644 (file)
--- 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 5828654f6bd390a37e5bd2148bc6c1ee95943105..1d2cbf74f424089cc77214fc6c640e4df8b6de11 100644 (file)
--- 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;