->getevents() should take unsigned args
[fio.git] / log.c
diff --git a/log.c b/log.c
index b5c6f690d4572770557462cad1b80201317fb814..039e74b25e77c5098631b83d1e0fbf16b26b0e27 100644 (file)
--- a/log.c
+++ b/log.c
@@ -57,8 +57,7 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
 
-restart:
-       if (!list_empty(&td->io_log_list)) {
+       while (!list_empty(&td->io_log_list)) {
                ipo = list_entry(td->io_log_list.next, struct io_piece, list);
                list_del(&ipo->list);
 
@@ -71,11 +70,11 @@ restart:
                        if (ipo->file_action == FIO_LOG_OPEN_FILE) {
                                assert(!td_io_open_file(td, f));
                                free(ipo);
-                               goto restart;
+                               continue;
                        } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) {
                                td_io_close_file(td, f);
                                free(ipo);
-                               goto restart;
+                               continue;
                        }
                }
 
@@ -92,6 +91,7 @@ restart:
                return 0;
        }
 
+       td->done = 1;
        return 1;
 }
 
@@ -174,9 +174,10 @@ static int read_iolog2(struct thread_data *td, FILE *f)
 {
        unsigned long long offset;
        unsigned int bytes;
-       int rw, reads, writes, fileno = 0, file_action = 0; /* stupid gcc */
+       int reads, writes, fileno = 0, file_action = 0; /* stupid gcc */
        char *fname, *act;
        char *str, *p;
+       enum fio_ddir rw;
 
        free_release_files(td);
 
@@ -232,9 +233,14 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                        
                if (rw == DDIR_READ)
                        reads++;
-               else if (rw == DDIR_WRITE)
+               else if (rw == DDIR_WRITE) {
                        writes++;
-               else if (rw != DDIR_SYNC && rw != DDIR_INVAL) {
+                       /*
+                        * Don't add a write for ro mode
+                        */
+                       if (read_only)
+                               continue;
+               } else if (rw != DDIR_SYNC && rw != DDIR_INVAL) {
                        log_err("bad ddir: %d\n", rw);
                        continue;
                }
@@ -247,7 +253,7 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                INIT_LIST_HEAD(&ipo->list);
                ipo->offset = offset;
                ipo->len = bytes;
-               ipo->ddir = (enum fio_ddir) rw;
+               ipo->ddir = rw;
                if (bytes > td->o.max_bs[rw])
                        td->o.max_bs[rw] = bytes;
                if (rw == DDIR_INVAL) {
@@ -255,12 +261,18 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                        ipo->file_action = file_action;
                }
                list_add_tail(&ipo->list, &td->io_log_list);
+               td->total_io_size += bytes;
        }
 
        free(str);
        free(act);
        free(fname);
 
+       if (writes && read_only) {
+               log_err("fio: <%s> skips replay of %d writes due to read-only\n", td->o.name, writes);
+               writes = 0;
+       }
+
        if (!reads && !writes)
                return 1;
        else if (reads && !writes)
@@ -281,7 +293,8 @@ static int read_iolog(struct thread_data *td, FILE *f)
        unsigned long long offset;
        unsigned int bytes;
        char *str, *p;
-       int rw, reads, writes;
+       int reads, writes;
+       int rw;
 
        /*
         * Read in the read iolog and store it, reuse the infrastructure
@@ -298,9 +311,14 @@ static int read_iolog(struct thread_data *td, FILE *f)
                }
                if (rw == DDIR_READ)
                        reads++;
-               else if (rw == DDIR_WRITE)
+               else if (rw == DDIR_WRITE) {
                        writes++;
-               else if (rw != DDIR_SYNC) {
+                       /*
+                        * Don't add a write for ro mode
+                        */
+                       if (read_only)
+                               continue;
+               } else if (rw != DDIR_SYNC) {
                        log_err("bad ddir: %d\n", rw);
                        continue;
                }
@@ -314,10 +332,16 @@ static int read_iolog(struct thread_data *td, FILE *f)
                if (bytes > td->o.max_bs[rw])
                        td->o.max_bs[rw] = bytes;
                list_add_tail(&ipo->list, &td->io_log_list);
+               td->total_io_size += bytes;
        }
 
        free(str);
 
+       if (writes && read_only) {
+               log_err("fio: <%s> skips replay of %d writes due to read-only\n", td->o.name, writes);
+               writes = 0;
+       }
+
        if (!reads && !writes)
                return 1;
        else if (reads && !writes)