Tweak handling of write traces with --readonly
authorJens Axboe <jens.axboe@oracle.com>
Fri, 7 Mar 2008 12:39:59 +0000 (13:39 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 7 Mar 2008 12:39:59 +0000 (13:39 +0100)
Don't add them at all, that allows us to replay a trace with writes
included when the --readonly switch is set. Before it would tell you
that it was 'X' number of writes, and then fail when it tried to
replay then anyway. Now just don't add those events.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
log.c

diff --git a/log.c b/log.c
index aea0398ec691bb034910f0c545bc5bd214dc8306..86de3e83c5682c8b83841ff98de4cad9bf1a3196 100644 (file)
--- a/log.c
+++ b/log.c
@@ -70,9 +70,15 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
                        struct fio_file *f = td->files[ipo->fileno];
 
                        if (ipo->file_action == FIO_LOG_OPEN_FILE) {
-                               assert(!td_io_open_file(td, f));
-                               free(ipo);
-                               continue;
+                               int ret;
+
+                               ret = td_io_open_file(td, f);
+                               if (!ret) {
+                                       free(ipo);
+                                       continue;
+                               }
+                               td_verror(td, ret, "iolog open file");
+                               return 1;
                        } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) {
                                td_io_close_file(td, f);
                                free(ipo);
@@ -247,12 +253,12 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                if (rw == DDIR_READ)
                        reads++;
                else if (rw == DDIR_WRITE) {
-                       writes++;
                        /*
                         * Don't add a write for ro mode
                         */
                        if (read_only)
                                continue;
+                       writes++;
                } else if (rw != DDIR_SYNC && rw != DDIR_INVAL) {
                        log_err("bad ddir: %d\n", rw);
                        continue;
@@ -326,12 +332,12 @@ static int read_iolog(struct thread_data *td, FILE *f)
                if (rw == DDIR_READ)
                        reads++;
                else if (rw == DDIR_WRITE) {
-                       writes++;
                        /*
                         * Don't add a write for ro mode
                         */
                        if (read_only)
                                continue;
+                       writes++;
                } else if (rw != DDIR_SYNC) {
                        log_err("bad ddir: %d\n", rw);
                        continue;