Add support for reading iolog from stdin.
authordonny372 <51675586+donny372@users.noreply.github.com>
Wed, 17 Jun 2020 19:58:22 +0000 (12:58 -0700)
committerShundong Zhou <shundong@google.com>
Sat, 8 Aug 2020 00:14:38 +0000 (17:14 -0700)
Add support for reading iolog from stdin and update HOWTO and man page.

Fixes: https://github.com/axboe/fio/issues/997

Signed-off-by: Shundong Zhou <donny372@gmail.com>
HOWTO
fio.1
init.c
iolog.c

diff --git a/HOWTO b/HOWTO
index 8cf8d6506b219e0f9933813616a7d682218adb24..3c8fbd83adde00d9fc65ae4d4365d11189f39e8e 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -2613,6 +2613,9 @@ I/O replay
        character. See the :option:`filename` option for information on how to
        escape ':' characters within the file names. These files will
        be sequentially assigned to job clones created by :option:`numjobs`.
+       '-' is a reserved name, meaning read from stdin, notably if
+       :option:`filename` is set to '-' which means stdin as well, then
+       this flag can't be set to '-'.
 
 .. option:: read_iolog_chunked=bool
 
diff --git a/fio.1 b/fio.1
index f134e0bf88ca9f958f1e8bdec594f3551e1ceb9d..71ea0731076a389ae1f1b506cf3386c1d676793b 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -2327,7 +2327,9 @@ replay, the file needs to be turned into a blkparse binary data file first
 You can specify a number of files by separating the names with a ':' character.
 See the \fBfilename\fR option for information on how to escape ':'
 characters within the file names. These files will be sequentially assigned to
-job clones created by \fBnumjobs\fR.
+job clones created by \fBnumjobs\fR. '-' is a reserved name, meaning read from
+stdin, notably if \fBfilename\fR is set to '-' which means stdin as well,
+then this flag can't be set to '-'.
 .TP
 .BI read_iolog_chunked \fR=\fPbool
 Determines how iolog is read. If false (default) entire \fBread_iolog\fR will
diff --git a/init.c b/init.c
index e53be35a7bed07ab0ff4ed06e2e7d564585793f8..e4a9ba6b57751f247bd4e942c19a2583a8c13c10 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2062,6 +2062,18 @@ static int __parse_jobs_ini(struct thread_data *td,
                }
 
                ret = fio_options_parse(td, opts, num_opts);
+
+               if (!ret) {
+                       if (!strcmp(file, "-") && td->o.read_iolog_file != NULL) {
+                               char *fname = get_name_by_idx(td->o.read_iolog_file,
+                                                             td->subjob_number);
+                               if (!strcmp(fname, "-")) {
+                                       log_err("fio: we can't read both iolog "
+                                               "and job file from stdin.\n");
+                                       ret = 1;
+                               }
+                       }
+               }
                if (!ret) {
                        if (dump_cmdline)
                                dump_opt_list(td);
diff --git a/iolog.c b/iolog.c
index 4a79fc4667fc13eff4c62b9206a0dfefe0a5dfd4..d5a18582c0301f8685566c72cc6603c316e90160 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -619,6 +619,8 @@ static bool init_iolog_read(struct thread_data *td)
                fd = open_socket(fname);
                if (fd >= 0)
                        f = fdopen(fd, "r");
+       } else if (!strcmp(fname, "-")) {
+               f = stdin;
        } else
                f = fopen(fname, "r");