Add more job info
authorJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 09:25:24 +0000 (10:25 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 09:25:24 +0000 (10:25 +0100)
Adds a specific command to be sent when a job is received by
the backend. Helps fill out the GUI fields for job values.

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

index d80123648207b13ec13e1896783c895f2c7cda31..a84b92c4739ff7f83492b49d8567a70776893226 100644 (file)
--- a/client.c
+++ b/client.c
@@ -911,6 +911,11 @@ int fio_handle_client(struct fio_client *client, struct client_ops *ops)
                handle_stop(client, cmd);
                free(cmd);
                break;
+       case FIO_NET_CMD_ADD_JOB:
+               if (ops->add_job)
+                       ops->add_job(client, cmd);
+               free(cmd);
+               break;
        default:
                log_err("fio: unknown client op: %s\n", fio_server_op(cmd->opcode));
                free(cmd);
index 0071484121c38136d457f367dc907cedd49fb171..ea297897957a4a9073a6fd24ebf50947785a74a7 100644 (file)
--- a/client.h
+++ b/client.h
@@ -48,20 +48,14 @@ struct fio_client {
 
 typedef void (*client_text_op_func)(struct fio_client *client,
                FILE *f, __u16 pdu_len, const char *buf);
-
 typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
-
 typedef void (*client_thread_status_op)(struct fio_net_cmd *cmd);
-
 typedef void (*client_group_stats_op)(struct fio_net_cmd *cmd);
-
 typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd);
-
 typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
-
 typedef void (*client_thread_status_display_op)(char *status_message, double perc);
-
 typedef void (*client_quit_op)(struct fio_client *);
+typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *);
 
 struct client_ops {
        client_text_op_func text_op;
@@ -71,6 +65,7 @@ struct client_ops {
        client_eta_op eta;
        client_probe_op probe;
        client_quit_op quit;
+       client_add_job_op add_job;
        int stay_connected;
 };
 
@@ -98,6 +93,5 @@ extern int fio_handle_clients(struct client_ops *ops);
 extern int fio_client_add(const char *, void **);
 extern struct fio_client *fio_client_add_explicit(const char *, int, int);
 extern void fio_client_add_cmd_option(void *, const char *);
-
 #endif
 
diff --git a/gfio.c b/gfio.c
index 848e511a8157c975355d36e5a2580fe701e116f4..20831c830a03e88150556f03e73e57ccdae8f5b0 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -59,6 +59,10 @@ struct probe_widget {
 };
 
 struct eta_widget {
+       GtkWidget *name;
+       GtkWidget *iotype;
+       GtkWidget *ioengine;
+       GtkWidget *iodepth;
        GtkWidget *jobs;
        GtkWidget *files;
        GtkWidget *read_bw;
@@ -117,6 +121,7 @@ static void gfio_set_connected(struct gui *ui, int connected)
 static void gfio_text_op(struct fio_client *client,
                 FILE *f, __u16 pdu_len, const char *buf)
 {
+#if 0
        GtkTextBuffer *buffer;
        GtkTextIter end;
 
@@ -127,6 +132,9 @@ static void gfio_text_op(struct fio_client *client,
        gdk_threads_leave();
        gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(ui.textview),
                                        &end, 0.0, FALSE, 0.0,0.0);
+#else
+       fio_client_ops.text_op(client, f, pdu_len, buf);
+#endif
 }
 
 static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
@@ -286,6 +294,32 @@ static void gfio_quit_op(struct fio_client *client)
        gfio_set_connected(ui, 0);
 }
 
+static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+       struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload;
+       struct gui *ui = client->client_data;
+       char tmp[8];
+       int i;
+
+       p->iodepth              = le32_to_cpu(p->iodepth);
+       p->rw                   = le32_to_cpu(p->rw);
+
+       for (i = 0; i < 2; i++) {
+               p->min_bs[i]    = le32_to_cpu(p->min_bs[i]);
+               p->max_bs[i]    = le32_to_cpu(p->max_bs[i]);
+       }
+
+       p->numjobs              = le32_to_cpu(p->numjobs);
+       p->group_reporting      = le32_to_cpu(p->group_reporting);
+
+       gtk_label_set_text(GTK_LABEL(ui->eta.name), (gchar *) p->jobname);
+       gtk_label_set_text(GTK_LABEL(ui->eta.iotype), ddir_str(p->rw));
+       gtk_label_set_text(GTK_LABEL(ui->eta.ioengine), (gchar *) p->ioengine);
+
+       sprintf(tmp, "%u", p->iodepth);
+       gtk_label_set_text(GTK_LABEL(ui->eta.iodepth), tmp);
+}
+
 struct client_ops gfio_client_ops = {
        .text_op                = gfio_text_op,
        .disk_util              = gfio_disk_util_op,
@@ -294,6 +328,7 @@ struct client_ops gfio_client_ops = {
        .eta                    = gfio_eta_op,
        .probe                  = gfio_probe_op,
        .quit                   = gfio_quit_op,
+       .add_job                = gfio_add_job_op,
        .stay_connected         = 1,
 };
 
@@ -694,6 +729,11 @@ static void init_ui(int *argc, char **argv[], struct gui *ui)
 
        probe_box = gtk_hbox_new(FALSE, 3);
        gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
+
+       ui->eta.name = new_info_label_in_frame(probe_box, "Name");
+       ui->eta.iotype = new_info_label_in_frame(probe_box, "IO");
+       ui->eta.ioengine = new_info_label_in_frame(probe_box, "IO Engine");
+       ui->eta.iodepth = new_info_label_in_frame(probe_box, "IO Depth");
        ui->eta.jobs = new_info_label_in_frame(probe_box, "Jobs");
        ui->eta.files = new_info_label_in_frame(probe_box, "Open files");
 
@@ -701,15 +741,22 @@ static void init_ui(int *argc, char **argv[], struct gui *ui)
        gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
        ui->eta.read_bw = new_info_label_in_frame(probe_box, "Read BW");
        ui->eta.read_iops = new_info_label_in_frame(probe_box, "IOPS");
-       ui->eta.cr_bw = new_info_label_in_frame(probe_box, "Commit BW");
-       ui->eta.cr_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
+       ui->eta.write_bw = new_info_label_in_frame(probe_box, "Write BW");
+       ui->eta.write_iops = new_info_label_in_frame(probe_box, "IOPS");
 
+       /*
+        * Only add this if we have a commit rate
+        */
+#if 0
        probe_box = gtk_hbox_new(FALSE, 3);
        gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3);
-       ui->eta.write_bw = new_info_label_in_frame(probe_box, "Write BW");
-       ui->eta.write_iops = new_info_label_in_frame(probe_box, "IOPS");
+
+       ui->eta.cr_bw = new_info_label_in_frame(probe_box, "Commit BW");
+       ui->eta.cr_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
+
        ui->eta.cw_bw = new_info_label_in_frame(probe_box, "Commit BW");
        ui->eta.cw_iops = new_info_label_in_frame(probe_box, "Commit IOPS");
+#endif
 
        /*
         * Add a text box for text op messages 
diff --git a/init.c b/init.c
index 2bdc71f19871023da67037a44ad17916fdd0f34e..f1446ca18550d4112c3d50345f309eb3ba44d87e 100644 (file)
--- a/init.c
+++ b/init.c
@@ -737,8 +737,6 @@ int ioengine_load(struct thread_data *td)
  */
 static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
 {
-       const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
-                                  "randread", "randwrite", "randrw" };
        unsigned int i;
        char fname[PATH_MAX];
        int numjobs, file_alloced;
@@ -850,6 +848,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
 
        if (!terse_output) {
                if (!job_add_num) {
+                       if (is_backend)
+                               fio_server_send_add_job(&td->o, td->io_ops->name);
+
                        if (!strcmp(td->io_ops->name, "cpuio")) {
                                log_info("%s: ioengine=cpu, cpuload=%u,"
                                         " cpucycle=%u\n", td->o.name,
@@ -866,7 +867,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                                log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s,"
                                         " ioengine=%s, iodepth=%u\n",
                                                td->o.name, td->groupid,
-                                               ddir_str[td->o.td_ddir],
+                                               ddir_str(td->o.td_ddir),
                                                c1, c2, c3, c4,
                                                td->io_ops->name,
                                                td->o.iodepth);
index b234256243db00b1ea608f07173709618c47d5b9..908101aae7add6dcc1b587975ea7838572fbcc20 100644 (file)
--- a/io_ddir.h
+++ b/io_ddir.h
@@ -39,4 +39,12 @@ static inline int ddir_rw(enum fio_ddir ddir)
        return ddir == DDIR_READ || ddir == DDIR_WRITE;
 }
 
+static inline const char *ddir_str(enum fio_ddir ddir)
+{
+       const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
+                                  "randread", "randwrite", "randrw" };
+
+       return ddir_str[ddir];
+}
+
 #endif
index a2db9dd5ccfdd5352894e0a1a4451d1ece22ebe6..490c277a8693d2b02e1263e51931cddd213566f8 100644 (file)
--- a/server.c
+++ b/server.c
@@ -52,6 +52,7 @@ static const char *fio_server_ops[FIO_NET_CMD_NR] = {
        "STOP",
        "DISK_UTIL",
        "RUN",
+       "ADD_JOB",
 };
 
 const char *fio_server_op(unsigned int op)
@@ -801,6 +802,28 @@ void fio_server_send_du(void)
        }
 }
 
+void fio_server_send_add_job(struct thread_options *o, const char *ioengine)
+{
+       struct cmd_add_job_pdu pdu;
+       int i;
+
+       strcpy((char *) pdu.jobname, o->name);
+       strcpy((char *) pdu.ioengine, ioengine);
+
+       pdu.iodepth             = cpu_to_le32(o->iodepth);
+       pdu.rw                  = cpu_to_le32(o->td_ddir);
+
+       for (i = 0; i < 2; i++) {
+               pdu.min_bs[i]   = cpu_to_le32(o->min_bs[i]);
+               pdu.max_bs[i]   = cpu_to_le32(o->max_bs[i]);
+       }
+
+       pdu.numjobs             = cpu_to_le32(o->numjobs);
+       pdu.group_reporting     = cpu_to_le32(o->group_reporting);
+
+       fio_net_send_cmd(server_fd, FIO_NET_CMD_ADD_JOB, &pdu, sizeof(pdu), 0);
+}
+
 int fio_server_log(const char *format, ...)
 {
        char buffer[1024];
index d17c0cea1486347d58b86aac2ed3ddba80a7fb23..5c7c8db9fcbb006b0414453d69085e37e34ed150 100644 (file)
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_int_cmd {
 };
 
 enum {
-       FIO_SERVER_VER          = 7,
+       FIO_SERVER_VER          = 8,
 
        FIO_SERVER_MAX_PDU      = 1024,
 
@@ -56,7 +56,8 @@ enum {
        FIO_NET_CMD_STOP        = 12,
        FIO_NET_CMD_DU          = 13,
        FIO_NET_CMD_RUN         = 14,
-       FIO_NET_CMD_NR          = 15,
+       FIO_NET_CMD_ADD_JOB     = 15,
+       FIO_NET_CMD_NR          = 16,
 
        FIO_NET_CMD_F_MORE      = 1UL << 0,
 
@@ -106,6 +107,17 @@ struct cmd_end_pdu {
        uint32_t error;
 };
 
+struct cmd_add_job_pdu {
+       uint8_t jobname[32];
+       uint8_t ioengine[32];
+       uint32_t iodepth;
+       uint32_t rw;
+       uint32_t min_bs[2];
+       uint32_t max_bs[2];
+       uint32_t numjobs;
+       uint32_t group_reporting;
+};
+
 extern int fio_start_server(char *);
 extern int fio_server_text_output(const char *, size_t);
 extern int fio_server_log(const char *format, ...);
@@ -129,6 +141,9 @@ extern int fio_send_data(int sk, const void *p, unsigned int len);
 extern void fio_net_cmd_crc(struct fio_net_cmd *);
 extern struct fio_net_cmd *fio_net_recv_cmd(int sk);
 
+struct thread_options;
+extern void fio_server_send_add_job(struct thread_options *, const char *);
+
 extern int exit_backend;
 extern int fio_net_port;