X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=gfio.c;h=2a38da56dd20255bd49ccc728342441ae92a6ad5;hb=ef4ad58a0ebcfe44611b787ba18503f1c6db9247;hp=be0a4ac3df28f97c5f053017c18cc36ed109316f;hpb=60d0929e4b8a1f6f4b400247d2fa017aa631d5fd;p=fio.git diff --git a/gfio.c b/gfio.c index be0a4ac3..2a38da56 100644 --- a/gfio.c +++ b/gfio.c @@ -52,16 +52,16 @@ static void send_clicked(GtkWidget *widget, gpointer data); static struct button_spec { const char *buttontext; clickfunction f; - const char *tooltiptext; - const int start_insensitive; + const char *tooltiptext[2]; + const int start_sensitive; } buttonspeclist[] = { #define CONNECT_BUTTON 0 #define SEND_BUTTON 1 #define START_JOB_BUTTON 2 - { "Connect", connect_clicked, "Connect to host", 0 }, - { "Send", send_clicked, "Send job description to host", 1 }, + { "Connect", connect_clicked, { "Disconnect from host", "Connect to host" }, 1 }, + { "Send", send_clicked, { "Send job description to host", NULL }, 0 }, { "Start Job", start_job_clicked, - "Start the current job on the server", 1 }, + { "Start the current job on the server", NULL }, 0 }, }; struct probe_widget { @@ -157,11 +157,11 @@ struct gui_entry { GtkWidget *notebook; GtkWidget *error_info_bar; GtkWidget *error_label; - GtkWidget *results_notebook; GtkWidget *results_window; + GtkWidget *results_notebook; GtkUIManager *results_uimanager; - GtkWidget *results_vbox; GtkWidget *results_menu; + GtkWidget *disk_util_vbox; GtkListStore *log_model; GtkWidget *log_tree; GtkWidget *log_view; @@ -188,14 +188,14 @@ struct end_results { struct gfio_client { struct gui_entry *ge; struct fio_client *client; - GtkWidget *results_widget; - GtkWidget *disk_util_vbox; GtkWidget *err_entry; - unsigned int job_added; struct thread_options o; struct end_results *results; unsigned int nr_results; + + struct cmd_du_pdu *du; + unsigned int nr_du; }; static void gfio_update_thread_status(struct gui_entry *ge, char *status_message, double perc); @@ -432,6 +432,39 @@ static void set_view_results_visible(struct gui *ui, int visible) set_menu_entry_visible(ui, "/MainMenu/ViewMenu/Results", visible); } +static const char *get_button_tooltip(struct button_spec *s, int sensitive) +{ + if (s->tooltiptext[sensitive]) + return s->tooltiptext[sensitive]; + + return s->tooltiptext[0]; +} + +static GtkWidget *add_button(GtkWidget *buttonbox, + struct button_spec *buttonspec, gpointer data) +{ + GtkWidget *button = gtk_button_new_with_label(buttonspec->buttontext); + gboolean sens = buttonspec->start_sensitive; + + g_signal_connect(button, "clicked", G_CALLBACK(buttonspec->f), data); + gtk_box_pack_start(GTK_BOX(buttonbox), button, FALSE, FALSE, 3); + + sens = buttonspec->start_sensitive; + gtk_widget_set_tooltip_text(button, get_button_tooltip(buttonspec, sens)); + gtk_widget_set_sensitive(button, sens); + + return button; +} + +static void add_buttons(struct gui_entry *ge, struct button_spec *buttonlist, + int nbuttons) +{ + int i; + + for (i = 0; i < nbuttons; i++) + ge->button[i] = add_button(ge->buttonbox, &buttonlist[i], ge); +} + /* * Update sensitivity of job buttons and job menu items, based on the * state of the client. @@ -498,6 +531,7 @@ static void update_button_states(struct gui *ui, struct gui_entry *ge) gtk_widget_set_sensitive(ge->button[SEND_BUTTON], send_state); gtk_widget_set_sensitive(ge->button[START_JOB_BUTTON], start_state); gtk_button_set_label(GTK_BUTTON(ge->button[CONNECT_BUTTON]), connect_str); + gtk_widget_set_tooltip_text(ge->button[CONNECT_BUTTON], get_button_tooltip(&buttonspeclist[CONNECT_BUTTON], connect_state)); set_menu_entry_visible(ui, "/MainMenu/JobMenu/Connect", connect_state); set_menu_entry_text(ui, "/MainMenu/JobMenu/Connect", connect_str); @@ -1247,6 +1281,110 @@ static GtkWidget *get_results_window(struct gui_entry *ge) return ge->results_notebook; } +static void disk_util_destroy(GtkWidget *w, gpointer data) +{ + struct gui_entry *ge = (struct gui_entry *) data; + + ge->disk_util_vbox = NULL; + gtk_widget_destroy(w); +} + +static int __gfio_disk_util_show(GtkWidget *res_notebook, + struct gfio_client *gc, struct cmd_du_pdu *p) +{ + GtkWidget *box, *frame, *entry, *vbox; + struct gui_entry *ge = gc->ge; + double util; + char tmp[16]; + + res_notebook = get_results_window(ge); + + if (!ge->disk_util_vbox) { + vbox = gtk_vbox_new(FALSE, 3); + gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), vbox, gtk_label_new("Disk utilization")); + ge->disk_util_vbox = vbox; + g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge); + } + + vbox = gtk_vbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(ge->disk_util_vbox), vbox); + + frame = gtk_frame_new((char *) p->dus.name); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2); + + box = gtk_vbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(frame), box); + + frame = gtk_frame_new("Read"); + gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); + vbox = gtk_hbox_new(TRUE, 3); + gtk_container_add(GTK_CONTAINER(frame), vbox); + entry = new_info_entry_in_frame(vbox, "IOs"); + entry_set_int_value(entry, p->dus.ios[0]); + entry = new_info_entry_in_frame(vbox, "Merges"); + entry_set_int_value(entry, p->dus.merges[0]); + entry = new_info_entry_in_frame(vbox, "Sectors"); + entry_set_int_value(entry, p->dus.sectors[0]); + entry = new_info_entry_in_frame(vbox, "Ticks"); + entry_set_int_value(entry, p->dus.ticks[0]); + + frame = gtk_frame_new("Write"); + gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); + vbox = gtk_hbox_new(TRUE, 3); + gtk_container_add(GTK_CONTAINER(frame), vbox); + entry = new_info_entry_in_frame(vbox, "IOs"); + entry_set_int_value(entry, p->dus.ios[1]); + entry = new_info_entry_in_frame(vbox, "Merges"); + entry_set_int_value(entry, p->dus.merges[1]); + entry = new_info_entry_in_frame(vbox, "Sectors"); + entry_set_int_value(entry, p->dus.sectors[1]); + entry = new_info_entry_in_frame(vbox, "Ticks"); + entry_set_int_value(entry, p->dus.ticks[1]); + + frame = gtk_frame_new("Shared"); + gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); + vbox = gtk_hbox_new(TRUE, 3); + gtk_container_add(GTK_CONTAINER(frame), vbox); + entry = new_info_entry_in_frame(vbox, "IO ticks"); + entry_set_int_value(entry, p->dus.io_ticks); + entry = new_info_entry_in_frame(vbox, "Time in queue"); + entry_set_int_value(entry, p->dus.time_in_queue); + + util = 0.0; + if (p->dus.msec) + util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec; + if (util > 100.0) + util = 100.0; + + sprintf(tmp, "%3.2f%%", util); + entry = new_info_entry_in_frame(vbox, "Disk utilization"); + gtk_entry_set_text(GTK_ENTRY(entry), tmp); + + gtk_widget_show_all(ge->results_window); + return 0; +} + +static int gfio_disk_util_show(struct gfio_client *gc) +{ + struct gui_entry *ge = gc->ge; + GtkWidget *res_notebook; + int i; + + if (!gc->nr_du) + return 1; + + res_notebook = get_results_window(ge); + + for (i = 0; i < gc->nr_du; i++) { + struct cmd_du_pdu *p = &gc->du[i]; + + __gfio_disk_util_show(res_notebook, gc, p); + } + + gtk_widget_show_all(ge->results_window); + return 0; +} + static void gfio_add_end_results(struct gfio_client *gc, struct thread_stat *ts, struct group_run_stats *rs) { @@ -1277,8 +1415,6 @@ static void __gfio_display_end_results(GtkWidget *win, struct gfio_client *gc, gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name)); - gc->results_widget = vbox; - entry = new_info_entry_in_frame(box, "Name"); gtk_entry_set_text(GTK_ENTRY(entry), ts->name); if (strlen(ts->description)) { @@ -1318,18 +1454,23 @@ static void gfio_display_end_results(struct gfio_client *gc) __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs); } - gtk_widget_show_all(ge->results_window); + if (gfio_disk_util_show(gc)) + gtk_widget_show_all(ge->results_window); } static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts, struct group_run_stats *rs) { struct gfio_client *gc = client->client_data; + struct gui_entry *ge = gc->ge; gfio_add_end_results(gc, ts, rs); gdk_threads_enter(); - gfio_display_end_results(gc); + if (ge->results_window) + __gfio_display_end_results(ge->results_notebook, gc, ts, rs); + else + gfio_display_end_results(gc); gdk_threads_leave(); } @@ -1365,79 +1506,18 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd { struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload; struct gfio_client *gc = client->client_data; - GtkWidget *box, *frame, *entry, *vbox; - double util; - char tmp[16]; - - gdk_threads_enter(); - - if (!gc->results_widget) - goto out; - - if (!gc->disk_util_vbox) { - frame = gtk_frame_new("Disk utilization"); - gtk_box_pack_start(GTK_BOX(gc->results_widget), frame, FALSE, FALSE, 5); - vbox = gtk_vbox_new(FALSE, 3); - gtk_container_add(GTK_CONTAINER(frame), vbox); - gc->disk_util_vbox = vbox; - } - - vbox = gtk_vbox_new(FALSE, 3); - gtk_container_add(GTK_CONTAINER(gc->disk_util_vbox), vbox); - - frame = gtk_frame_new((char *) p->dus.name); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2); - - box = gtk_vbox_new(FALSE, 3); - gtk_container_add(GTK_CONTAINER(frame), box); - - frame = gtk_frame_new("Read"); - gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); - vbox = gtk_hbox_new(TRUE, 3); - gtk_container_add(GTK_CONTAINER(frame), vbox); - entry = new_info_entry_in_frame(vbox, "IOs"); - entry_set_int_value(entry, p->dus.ios[0]); - entry = new_info_entry_in_frame(vbox, "Merges"); - entry_set_int_value(entry, p->dus.merges[0]); - entry = new_info_entry_in_frame(vbox, "Sectors"); - entry_set_int_value(entry, p->dus.sectors[0]); - entry = new_info_entry_in_frame(vbox, "Ticks"); - entry_set_int_value(entry, p->dus.ticks[0]); - - frame = gtk_frame_new("Write"); - gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); - vbox = gtk_hbox_new(TRUE, 3); - gtk_container_add(GTK_CONTAINER(frame), vbox); - entry = new_info_entry_in_frame(vbox, "IOs"); - entry_set_int_value(entry, p->dus.ios[1]); - entry = new_info_entry_in_frame(vbox, "Merges"); - entry_set_int_value(entry, p->dus.merges[1]); - entry = new_info_entry_in_frame(vbox, "Sectors"); - entry_set_int_value(entry, p->dus.sectors[1]); - entry = new_info_entry_in_frame(vbox, "Ticks"); - entry_set_int_value(entry, p->dus.ticks[1]); - - frame = gtk_frame_new("Shared"); - gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); - vbox = gtk_hbox_new(TRUE, 3); - gtk_container_add(GTK_CONTAINER(frame), vbox); - entry = new_info_entry_in_frame(vbox, "IO ticks"); - entry_set_int_value(entry, p->dus.io_ticks); - entry = new_info_entry_in_frame(vbox, "Time in queue"); - entry_set_int_value(entry, p->dus.time_in_queue); - - util = 0.0; - if (p->dus.msec) - util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec; - if (util > 100.0) - util = 100.0; + struct gui_entry *ge = gc->ge; + unsigned int nr = gc->nr_du; - sprintf(tmp, "%3.2f%%", util); - entry = new_info_entry_in_frame(vbox, "Disk utilization"); - gtk_entry_set_text(GTK_ENTRY(entry), tmp); + gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu)); + memcpy(&gc->du[nr], p, sizeof(*p)); + gc->nr_du++; - gtk_widget_show_all(gc->results_widget); -out: + gdk_threads_enter(); + if (ge->results_window) + __gfio_disk_util_show(ge->results_notebook, gc, p); + else + gfio_disk_util_show(gc); gdk_threads_leave(); } @@ -1461,6 +1541,7 @@ static void gfio_thread_status_op(struct fio_client *client, sum_group_stats(&client_gs, &p->rs); client_ts.members++; + client_ts.thread_number = p->ts.thread_number; client_ts.groupid = p->ts.groupid; if (++sum_stat_nr == sum_stat_clients) { @@ -1788,6 +1869,8 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd) struct gui_entry *ge = gc->ge; char tmp[8]; + p->thread_number = le32_to_cpu(p->thread_number); + p->groupid = le32_to_cpu(p->groupid); convert_thread_options_to_cpu(o, &p->top); gdk_threads_enter(); @@ -1807,8 +1890,6 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd) multitext_set_entry(&ge->eta.ioengine, 0); multitext_set_entry(&ge->eta.iodepth, 0); - gc->job_added++; - gfio_set_state(ge, GE_STATE_JOB_SENT); gdk_threads_leave(); @@ -2015,6 +2096,8 @@ static void connect_clicked(GtkWidget *widget, gpointer data) if (!ge->nr_job_files) return; + gc = ge->client; + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), "No jobs running"); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), 0.0); ret = fio_client_connect(gc->client); @@ -2051,28 +2134,6 @@ static void send_clicked(GtkWidget *widget, gpointer data) } } -static GtkWidget *add_button(GtkWidget *buttonbox, - struct button_spec *buttonspec, gpointer data) -{ - GtkWidget *button = gtk_button_new_with_label(buttonspec->buttontext); - - g_signal_connect(button, "clicked", G_CALLBACK(buttonspec->f), data); - gtk_box_pack_start(GTK_BOX(buttonbox), button, FALSE, FALSE, 3); - gtk_widget_set_tooltip_text(button, buttonspec->tooltiptext); - gtk_widget_set_sensitive(button, !buttonspec->start_insensitive); - - return button; -} - -static void add_buttons(struct gui_entry *ge, struct button_spec *buttonlist, - int nbuttons) -{ - int i; - - for (i = 0; i < nbuttons; i++) - ge->button[i] = add_button(ge->buttonbox, &buttonlist[i], ge); -} - static void on_info_bar_response(GtkWidget *widget, gint response, gpointer data) { @@ -2629,7 +2690,6 @@ static void view_results(GtkWidget *w, gpointer data) gfio_display_end_results(gc); } - static void __update_graph_limits(struct gfio_graphs *g) { line_graph_set_data_count_limit(g->iops_graph, gfio_graph_limit); @@ -2806,9 +2866,9 @@ static const gchar *ui_string = " \ \ \ \ + \ \ \ - \ \ \ \