gfio: handle clients individually
authorJens Axboe <axboe@kernel.dk>
Fri, 9 Mar 2012 14:14:06 +0000 (15:14 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 9 Mar 2012 14:14:06 +0000 (15:14 +0100)
Now we have per-client support, don't use any of the "do FOO for
all clients" functions.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
client.h
gfio.c

index af1dba44ff77d8f8d0d11b6d90fda29521a2b8cf..225f6643e5aaa0ec283f35f8903415789debb3b7 100644 (file)
--- a/client.c
+++ b/client.c
@@ -495,7 +495,7 @@ int fio_start_all_clients(void)
  * Send file contents to server backend. We could use sendfile(), but to remain
  * more portable lets just read/write the darn thing.
  */
-static int fio_client_send_ini(struct fio_client *client, const char *filename)
+static int __fio_client_send_ini(struct fio_client *client, const char *filename)
 {
        struct stat sb;
        char *p, *buf;
@@ -548,6 +548,17 @@ static int fio_client_send_ini(struct fio_client *client, const char *filename)
        return ret;
 }
 
+int fio_client_send_ini(struct fio_client *client, const char *filename)
+{
+       if (__fio_client_send_ini(client, filename)) {
+               remove_client(client);
+               return 1;
+       }
+
+       client->sent_job = 1;
+       return 0;
+}
+
 int fio_clients_send_ini(const char *filename)
 {
        struct fio_client *client;
@@ -556,10 +567,7 @@ int fio_clients_send_ini(const char *filename)
        flist_for_each_safe(entry, tmp, &client_list) {
                client = flist_entry(entry, struct fio_client, list);
 
-               if (fio_client_send_ini(client, filename))
-                       remove_client(client);
-
-               client->sent_job = 1;
+               fio_client_send_ini(client, filename);
        }
 
        return !nr_clients;
index ab093171271590e322627aa7c3c4248eab6059ad..e280adbd54f4f5531a4232d8e83f1962a5c3b501 100644 (file)
--- a/client.h
+++ b/client.h
@@ -107,6 +107,7 @@ extern int fio_client_connect(struct fio_client *);
 extern int fio_clients_connect(void);
 extern int fio_start_client(struct fio_client *);
 extern int fio_start_all_clients(void);
+extern int fio_client_send_ini(struct fio_client *, const char *);
 extern int fio_clients_send_ini(const char *);
 extern int fio_handle_clients(struct client_ops *);
 extern int fio_client_add(struct client_ops *, const char *, void **);
diff --git a/gfio.c b/gfio.c
index 1f85a491e199628ff0c00294bdec5808380f71b6..b0cab29a4839ee6287fa67529ae673451807d0f9 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -35,7 +35,6 @@
 static int gfio_server_running;
 static const char *gfio_graph_font;
 
-static void gfio_update_thread_status(char *status_message, double perc);
 static void view_log(GtkWidget *w, gpointer data);
 
 #define ARRAYSIZE(x) (sizeof((x)) / (sizeof((x)[0])))
@@ -170,6 +169,9 @@ struct gfio_client {
        struct thread_options o;
 };
 
+static void gfio_update_thread_status(struct gui_entry *ge, char *status_message, double perc);
+static void gfio_update_thread_status_all(char *status_message, double perc);
+
 static struct graph *setup_iops_graph(void)
 {
        struct graph *g;
@@ -1200,7 +1202,7 @@ static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *j
                sprintf(dst, " - %s", eta_str);
        }
                
-       gfio_update_thread_status(output, perc);
+       gfio_update_thread_status(ge, output, perc);
        gdk_threads_leave();
 }
 
@@ -1286,7 +1288,7 @@ static void gfio_update_all_eta(struct jobs_eta *je)
                sprintf(dst, " - %s", eta_str);
        }
                
-       gfio_update_thread_status(output, perc);
+       gfio_update_thread_status_all(output, perc);
        gdk_threads_leave();
 }
 
@@ -1322,7 +1324,19 @@ static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
        gdk_threads_leave();
 }
 
-static void gfio_update_thread_status(char *status_message, double perc)
+static void gfio_update_thread_status(struct gui_entry *ge,
+                                     char *status_message, double perc)
+{
+       static char message[100];
+       const char *m = message;
+
+       strncpy(message, status_message, sizeof(message) - 1);
+       gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), m);
+       gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), perc / 100.0);
+       gtk_widget_queue_draw(main_ui.window);
+}
+
+static void gfio_update_thread_status_all(char *status_message, double perc)
 {
        struct gui *ui = &main_ui;
        static char message[100];
@@ -1448,10 +1462,11 @@ static void *job_thread(void *arg)
 
 static int send_job_files(struct gui_entry *ge)
 {
+       struct gfio_client *gc = ge->client;
        int i, ret = 0;
 
        for (i = 0; i < ge->nr_job_files; i++) {
-               ret = fio_clients_send_ini(ge->job_files[i]);
+               ret = fio_client_send_ini(gc->client, ge->job_files[i]);
                if (ret)
                        break;