server: send network copy of run_str[]
authorJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 17:44:41 +0000 (19:44 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 17:44:41 +0000 (19:44 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
eta.c
server.c
stat.h

diff --git a/eta.c b/eta.c
index e8dfd28..5b912eb 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -343,6 +343,9 @@ int calc_thread_status(struct jobs_eta *je)
        if (!je->nr_running && !je->nr_pending)
                return 0;
 
+       je->nr_threads = thread_number;
+       memcpy(je->run_str, run_str, thread_number * sizeof(char));
+
        return 1;
 }
 
@@ -392,8 +395,8 @@ void display_thread_status(struct jobs_eta *je)
                iops_str[1] = num2str(je->iops[1], 4, 1, 0);
 
                l = sprintf(p, ": [%s] [%s] [%s/%s /s] [%s/%s iops] [eta %s]",
-                                run_str, perc_str, rate_str[0], rate_str[1],
-                                iops_str[0], iops_str[1], eta_str);
+                               je->run_str, perc_str, rate_str[0],
+                               rate_str[1], iops_str[0], iops_str[1], eta_str);
                p += l;
                if (l >= 0 && l < linelen_last)
                        p += sprintf(p, "%*s", linelen_last - l, "");
@@ -412,14 +415,16 @@ void display_thread_status(struct jobs_eta *je)
 
 void print_thread_status(void)
 {
-       struct jobs_eta je;
+       struct jobs_eta *je;
+
+       je = malloc(sizeof(*je) + thread_number * sizeof(char));
 
-       memset(&je, 0, sizeof(je));
+       memset(je, 0, sizeof(*je) + thread_number * sizeof(char));
 
-       if (!calc_thread_status(&je))
-               return;
+       if (calc_thread_status(je))
+               display_thread_status(je);
 
-       display_thread_status(&je);
+       free(je);
 }
 
 void print_status_init(int thr_number)
index 32add58..93f5d8e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -545,30 +545,40 @@ void fio_server_send_gs(struct group_run_stats *rs)
 
 void fio_server_send_status(void)
 {
-       struct jobs_eta je;
+       struct jobs_eta *je;
+       size_t size;
+       void *buf;
        int i;
 
-       if (!calc_thread_status(&je))
+       size = sizeof(*je) + thread_number * sizeof(char);
+       buf = malloc(size);
+       memset(buf, 0, size);
+       je = buf;
+
+       if (!calc_thread_status(je)) {
+               free(je);
                return;
+       }
 
-       je.nr_running           = cpu_to_le32(je.nr_running);
-       je.nr_ramp              = cpu_to_le32(je.nr_ramp);
-       je.nr_pending           = cpu_to_le32(je.nr_pending);
-       je.files_open           = cpu_to_le32(je.files_open);
-       je.m_rate               = cpu_to_le32(je.m_rate);
-       je.t_rate               = cpu_to_le32(je.t_rate);
-       je.m_iops               = cpu_to_le32(je.m_iops);
-       je.t_iops               = cpu_to_le32(je.t_iops);
+       je->nr_running          = cpu_to_le32(je->nr_running);
+       je->nr_ramp             = cpu_to_le32(je->nr_ramp);
+       je->nr_pending          = cpu_to_le32(je->nr_pending);
+       je->files_open          = cpu_to_le32(je->files_open);
+       je->m_rate              = cpu_to_le32(je->m_rate);
+       je->t_rate              = cpu_to_le32(je->t_rate);
+       je->m_iops              = cpu_to_le32(je->m_iops);
+       je->t_iops              = cpu_to_le32(je->t_iops);
 
        for (i = 0; i < 2; i++) {
-               je.rate[i]      = cpu_to_le32(je.rate[i]);
-               je.iops[i]      = cpu_to_le32(je.iops[i]);
+               je->rate[i]     = cpu_to_le32(je->rate[i]);
+               je->iops[i]     = cpu_to_le32(je->iops[i]);
        }
 
-       je.elapsed_sec          = cpu_to_le32(je.nr_running);
-       je.eta_sec              = cpu_to_le64(je.eta_sec);
+       je->elapsed_sec         = cpu_to_le32(je->nr_running);
+       je->eta_sec             = cpu_to_le64(je->eta_sec);
 
-       fio_net_send_cmd(server_fd, FIO_NET_CMD_ETA, &je, sizeof(je));
+       fio_net_send_cmd(server_fd, FIO_NET_CMD_ETA, buf, size);
+       free(je);
 }
 
 int fio_server_log(const char *format, ...)
diff --git a/stat.h b/stat.h
index 30b2d32..72cbe16 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -179,6 +179,12 @@ struct jobs_eta {
        uint32_t iops[2];
        uint64_t elapsed_sec;
        uint64_t eta_sec;
+
+       /*
+        * Network 'copy' of run_str[]
+        */
+       uint32_t nr_threads;
+       uint8_t run_str[0];
 };
 
 extern void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs);