Merge branch 'master' into gfio
[fio.git] / eta.c
diff --git a/eta.c b/eta.c
index 238a0af13079c433daab4512ccabb45c9ce226cc..531b876280b2176d3784d6d50073d2d47797e146 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -139,6 +139,15 @@ static int thread_eta(struct thread_data *td)
                bytes_total = td->fill_device_size;
        }
 
+       if (td->o.zone_size && td->o.zone_skip && bytes_total) {
+               unsigned int nr_zones;
+               uint64_t zone_bytes;
+
+               zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip;
+               nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip);
+               bytes_total -= nr_zones * td->o.zone_skip;
+       }
+
        /*
         * if writing and verifying afterwards, bytes_total will be twice the
         * size. In a mixed workload, verify phase will be the size of the
@@ -156,9 +165,6 @@ static int thread_eta(struct thread_data *td)
                        bytes_total <<= 1;
        }
 
-       if (td->o.zone_size && td->o.zone_skip)
-               bytes_total /= (td->o.zone_skip / td->o.zone_size);
-
        if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) {
                double perc, perc_t;
 
@@ -285,7 +291,8 @@ int calc_thread_status(struct jobs_eta *je, int force)
        static struct timeval rate_prev_time, disp_prev_time;
 
        if (!force) {
-               if (output_format != FIO_OUTPUT_NORMAL)
+               if (output_format != FIO_OUTPUT_NORMAL &&
+                   f_out == stdout)
                        return 0;
                if (temp_stall_ts || eta_print == FIO_ETA_NEVER)
                        return 0;
@@ -415,12 +422,13 @@ int calc_thread_status(struct jobs_eta *je, int force)
 
        je->nr_threads = thread_number;
        memcpy(je->run_str, run_str, thread_number * sizeof(char));
-
        return 1;
 }
 
 void display_thread_status(struct jobs_eta *je)
 {
+       static struct timeval disp_eta_new_line;
+       static int eta_new_line_init, eta_new_line_pending;
        static int linelen_last;
        static int eta_good;
        char output[REAL_MAX_JOBS + 512], *p = output;
@@ -432,6 +440,11 @@ void display_thread_status(struct jobs_eta *je)
                eta_to_str(eta_str, je->eta_sec);
        }
 
+       if (eta_new_line_pending) {
+               eta_new_line_pending = 0;
+               p += sprintf(p, "\n");
+       }
+
        p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open);
        if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
                char *tr, *mr;
@@ -488,6 +501,16 @@ void display_thread_status(struct jobs_eta *je)
        p += sprintf(p, "\r");
 
        printf("%s", output);
+
+       if (!eta_new_line_init) {
+               fio_gettime(&disp_eta_new_line, NULL);
+               eta_new_line_init = 1;
+       } else if (eta_new_line &&
+                  mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) {
+               fio_gettime(&disp_eta_new_line, NULL);
+               eta_new_line_pending = 1;
+       }
+
        fflush(stdout);
 }