[PATCH] Fix random_map
[fio.git] / eta.c
diff --git a/eta.c b/eta.c
index 9ad0b49bdb5b1798d5c3bbe77f9c5d08892f7a52..8cf9ea25eb6127f675c5a16d4a4d02a9ecf6d596 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -105,6 +105,17 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed)
 
        bytes_total = td->total_io_size;
 
+       /*
+        * if writing, bytes_total will be twice the size. If mixing,
+        * assume a 50/50 split and thus bytes_total will be 50% larger.
+        */
+       if (td->verify) {
+               if (td_rw(td))
+                       bytes_total = bytes_total * 3 / 2;
+               else
+                       bytes_total <<= 1;
+       }
+
        if (td->zone_size && td->zone_skip)
                bytes_total /= (td->zone_skip / td->zone_size);
 
@@ -161,6 +172,7 @@ void print_thread_status(void)
 {
        unsigned long elapsed = mtime_since_genesis() / 1000;
        int i, nr_running, nr_pending, t_rate, m_rate, *eta_secs, eta_sec;
+       struct thread_data *td;
        char eta_str[32];
        double perc = 0.0;
 
@@ -171,9 +183,7 @@ void print_thread_status(void)
        memset(eta_secs, 0, thread_number * sizeof(int));
 
        nr_pending = nr_running = t_rate = m_rate = 0;
-       for (i = 0; i < thread_number; i++) {
-               struct thread_data *td = &threads[i];
-
+       for_each_td(td, i) {
                if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING||
                    td->runstate == TD_FSYNCING) {
                        nr_running++;
@@ -195,7 +205,7 @@ void print_thread_status(void)
        else
                eta_sec = 0;
 
-       for (i = 0; i < thread_number; i++) {
+       for_each_td(td, i) {
                if (exitall_on_terminate) {
                        if (eta_secs[i] < eta_sec)
                                eta_sec = eta_secs[i];
@@ -205,6 +215,8 @@ void print_thread_status(void)
                }
        }
 
+       free(eta_secs);
+
        if (eta_sec != INT_MAX && elapsed) {
                perc = (double) elapsed / (double) (elapsed + eta_sec);
                eta_to_str(eta_str, eta_sec);
@@ -222,7 +234,6 @@ void print_thread_status(void)
        }
        printf("\r");
        fflush(stdout);
-       free(eta_secs);
 }
 
 void print_status_init(int thread_number)