iolog: Now --read_iolog can contain multiple replay files, separated by ':'.
authorAdam Kupczyk <akupczyk@redhat.com>
Fri, 17 Aug 2018 13:30:58 +0000 (15:30 +0200)
committerAdam Kupczyk <akupczyk@redhat.com>
Mon, 20 Aug 2018 11:23:29 +0000 (13:23 +0200)
    Useful when --numjobs is more then 1.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
fio.1
iolog.c
options.c
options.h

diff --git a/fio.1 b/fio.1
index 4386f8577b8c6f8a63eb12b40d65b22d9b77d2c1..11f81fb279af500b740d37f7f517bbb59eedb5ff 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -2056,6 +2056,10 @@ to replay a workload captured by blktrace. See
 \fBblktrace\fR\|(8) for how to capture such logging data. For blktrace
 replay, the file needs to be turned into a blkparse binary data file first
 (`blkparse <device> \-o /dev/null \-d file_for_fio.bin').
 \fBblktrace\fR\|(8) for how to capture such logging data. For blktrace
 replay, the file needs to be turned into a blkparse binary data file first
 (`blkparse <device> \-o /dev/null \-d file_for_fio.bin').
+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 ':' and '\'
+characters within the file names. These files will be sequentially assigned to
+job clones created by \fBnumjobs\fR.
 .TP
 .BI read_iolog_chunked \fR=\fPbool
 Determines how iolog is read. If false (default) entire \fBread_iolog\fR will
 .TP
 .BI read_iolog_chunked \fR=\fPbool
 Determines how iolog is read. If false (default) entire \fBread_iolog\fR will
diff --git a/iolog.c b/iolog.c
index 0f95c6080ea8d49fde24e868af82369d1dc7be2e..f3eedb56252c9b177c2f75d2d50e9a99a2b59696 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -447,7 +447,7 @@ static bool read_iolog2(struct thread_data *td)
                                        dprint(FD_FILE, "iolog: ignoring"
                                                " re-add of file %s\n", fname);
                                } else {
                                        dprint(FD_FILE, "iolog: ignoring"
                                                " re-add of file %s\n", fname);
                                } else {
-                                       fileno = add_file(td, fname, 0, 1);
+                                       fileno = add_file(td, fname, td->subjob_number, 1);
                                        file_action = FIO_LOG_ADD_FILE;
                                }
                                continue;
                                        file_action = FIO_LOG_ADD_FILE;
                                }
                                continue;
@@ -596,13 +596,17 @@ static bool init_iolog_read(struct thread_data *td)
        char buffer[256], *p;
        FILE *f = NULL;
        bool ret;
        char buffer[256], *p;
        FILE *f = NULL;
        bool ret;
-       if (is_socket(td->o.read_iolog_file)) {
-               int fd = open_socket(td->o.read_iolog_file);
+       char* fname = get_name_by_idx(td->o.read_iolog_file, td->subjob_number);
+       dprint(FD_IO, "iolog: name=%s\n", fname);
+
+       if (is_socket(fname)) {
+               int fd = open_socket(fname);
                if (fd >= 0) {
                        f = fdopen(fd, "r");
                }
        } else
                if (fd >= 0) {
                        f = fdopen(fd, "r");
                }
        } else
-               f = fopen(td->o.read_iolog_file, "r");
+               f = fopen(fname, "r");
+       free(fname);
        if (!f) {
                perror("fopen read iolog");
                return false;
        if (!f) {
                perror("fopen read iolog");
                return false;
index f5920278ad2cd15c8efa98eb6c50cd155de8f594..58395051aa6ce23bb4c553031f7f18d4604f8354 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1284,6 +1284,23 @@ int set_name_idx(char *target, size_t tlen, char *input, int index,
        return len;
 }
 
        return len;
 }
 
+char* get_name_by_idx(char *input, int index)
+{
+       unsigned int cur_idx;
+       char *fname, *str, *p;
+
+       p = str = strdup(input);
+
+       index %= get_max_name_idx(input);
+       for (cur_idx = 0; cur_idx <= index; cur_idx++)
+               fname = get_next_name(&str);
+
+       fname = strdup(fname);
+       free(p);
+
+       return fname;
+}
+
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = cb_data_to_td(data);
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = cb_data_to_td(data);
index e53eb1bc98155984e4f4990edd670d5ad5ebecf2..8fdd1363277500169b087ed79e06fc74d52fa24e 100644 (file)
--- a/options.h
+++ b/options.h
@@ -16,6 +16,7 @@ void add_opt_posval(const char *, const char *, const char *);
 void del_opt_posval(const char *, const char *);
 struct thread_data;
 void fio_options_free(struct thread_data *);
 void del_opt_posval(const char *, const char *);
 struct thread_data;
 void fio_options_free(struct thread_data *);
+char* get_name_by_idx(char *input, int index);
 int set_name_idx(char *, size_t, char *, int, bool);
 
 extern char client_sockaddr_str[];  /* used with --client option */
 int set_name_idx(char *, size_t, char *, int, bool);
 
 extern char client_sockaddr_str[];  /* used with --client option */