client/server: fixup "All clients" reporting
authorJens Axboe <axboe@kernel.dk>
Wed, 14 Nov 2012 20:09:45 +0000 (13:09 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 14 Nov 2012 20:09:45 +0000 (13:09 -0700)
We didn't properly account for no group_reporting and multiple
jobs on multiple connections.

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

index fd73eda08a326c073cf3a3e22891b5001a1fa535..b80c9038fee4155a1728bdd8559b7ed8f1735dcf 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -62,6 +62,7 @@ struct io_log *agg_io_log[DDIR_RWDIR_CNT];
 
 int groupid = 0;
 unsigned int thread_number = 0;
 
 int groupid = 0;
 unsigned int thread_number = 0;
+unsigned int stat_number = 0;
 unsigned int nr_process = 0;
 unsigned int nr_thread = 0;
 int shm_id = 0;
 unsigned int nr_process = 0;
 unsigned int nr_thread = 0;
 int shm_id = 0;
index bf09d7ef4dadad7a343ecda88a80aaca4e2053fe..a483913062cfb527f64c718356366cd6d2266c33 100644 (file)
--- a/client.c
+++ b/client.c
@@ -47,9 +47,11 @@ struct fio_client {
        int is_sock;
        int disk_stats_shown;
        unsigned int jobs;
        int is_sock;
        int disk_stats_shown;
        unsigned int jobs;
+       unsigned int nr_stat;
        int error;
        int ipv6;
        int sent_job;
        int error;
        int ipv6;
        int sent_job;
+       int did_stat;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
@@ -81,8 +83,9 @@ static FLIST_HEAD(arg_list);
 
 static struct thread_stat client_ts;
 static struct group_run_stats client_gs;
 
 static struct thread_stat client_ts;
 static struct group_run_stats client_gs;
-static int sum_stat_clients;
+static int sum_stat_clients = 0;
 static int sum_stat_nr;
 static int sum_stat_nr;
+static int do_output_all_clients;
 
 #define FIO_CLIENT_HASH_BITS   7
 #define FIO_CLIENT_HASH_SZ     (1 << FIO_CLIENT_HASH_BITS)
 
 #define FIO_CLIENT_HASH_BITS   7
 #define FIO_CLIENT_HASH_SZ     (1 << FIO_CLIENT_HASH_BITS)
@@ -159,9 +162,11 @@ static void remove_client(struct fio_client *client)
        if (client->ini_file)
                free(client->ini_file);
 
        if (client->ini_file)
                free(client->ini_file);
 
+       if (!client->did_stat)
+               sum_stat_clients -= client->nr_stat;
+
        free(client);
        nr_clients--;
        free(client);
        nr_clients--;
-       sum_stat_clients--;
 }
 
 static void put_client(struct fio_client *client)
 }
 
 static void put_client(struct fio_client *client)
@@ -664,7 +669,7 @@ static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
        dst->groupid    = le32_to_cpu(src->groupid);
 }
 
        dst->groupid    = le32_to_cpu(src->groupid);
 }
 
-static void handle_ts(struct fio_net_cmd *cmd)
+static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
 
 {
        struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
 
@@ -672,8 +677,9 @@ static void handle_ts(struct fio_net_cmd *cmd)
        convert_gs(&p->rs, &p->rs);
 
        show_thread_status(&p->ts, &p->rs);
        convert_gs(&p->rs, &p->rs);
 
        show_thread_status(&p->ts, &p->rs);
+       client->did_stat = 1;
 
 
-       if (sum_stat_clients == 1)
+       if (!do_output_all_clients)
                return;
 
        sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
                return;
 
        sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
@@ -870,6 +876,12 @@ static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd)
 
        client->state = Client_started;
        client->jobs = le32_to_cpu(pdu->jobs);
 
        client->state = Client_started;
        client->jobs = le32_to_cpu(pdu->jobs);
+       client->nr_stat = le32_to_cpu(pdu->stat_outputs);
+
+       if (sum_stat_clients > 1)
+               do_output_all_clients = 1;
+
+       sum_stat_clients += client->nr_stat;
 }
 
 static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
 }
 
 static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
@@ -921,7 +933,7 @@ static int handle_client(struct fio_client *client)
                free(cmd);
                break;
        case FIO_NET_CMD_TS:
                free(cmd);
                break;
        case FIO_NET_CMD_TS:
-               handle_ts(cmd);
+               handle_ts(client, cmd);
                free(cmd);
                break;
        case FIO_NET_CMD_GS:
                free(cmd);
                break;
        case FIO_NET_CMD_GS:
@@ -1053,7 +1065,6 @@ int fio_handle_clients(void)
 
        pfds = malloc(nr_clients * sizeof(struct pollfd));
 
 
        pfds = malloc(nr_clients * sizeof(struct pollfd));
 
-       sum_stat_clients = nr_clients;
        init_thread_stat(&client_ts);
        init_group_run_stat(&client_gs);
 
        init_thread_stat(&client_ts);
        init_group_run_stat(&client_gs);
 
diff --git a/fio.h b/fio.h
index ca1a5f061b3ce5e9c7e682ddf40a0ea17c740c56..f69de0d321bbcd6282c611f27e8b86483ff04b35 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -558,6 +558,7 @@ enum {
 
 extern int exitall_on_terminate;
 extern unsigned int thread_number;
 
 extern int exitall_on_terminate;
 extern unsigned int thread_number;
+extern unsigned int stat_number;
 extern unsigned int nr_process, nr_thread;
 extern int shm_id;
 extern int groupid;
 extern unsigned int nr_process, nr_thread;
 extern int shm_id;
 extern int groupid;
diff --git a/init.c b/init.c
index 23be863141a3ff670d84780eccb52b924ab0cb66..a682423e9801be03a120b6d038f0b8fd6c762c1c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -317,6 +317,10 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent,
        profile_add_hooks(td);
 
        td->thread_number = thread_number;
        profile_add_hooks(td);
 
        td->thread_number = thread_number;
+
+       if (!parent || !parent->o.group_reporting)
+               stat_number++;
+
        return td;
 }
 
        return td;
 }
 
index 72def7e003ee938a1c41f3d4a7e31d14b4ce3ce3..33b80d68620d103eb52feb93aafca7b765d9ef98 100644 (file)
--- a/server.c
+++ b/server.c
@@ -336,12 +336,15 @@ static int handle_job_cmd(struct fio_net_cmd *cmd)
        struct cmd_end_pdu epdu;
        int ret;
 
        struct cmd_end_pdu epdu;
        int ret;
 
+       stat_number = 0;
+
        if (parse_jobs_ini(buf, 1, 0)) {
                fio_server_send_quit_cmd();
                return -1;
        }
 
        spdu.jobs = cpu_to_le32(thread_number);
        if (parse_jobs_ini(buf, 1, 0)) {
                fio_server_send_quit_cmd();
                return -1;
        }
 
        spdu.jobs = cpu_to_le32(thread_number);
+       spdu.stat_outputs = cpu_to_le32(stat_number);
        fio_net_send_cmd(server_fd, FIO_NET_CMD_START, &spdu, sizeof(spdu), 0);
 
        ret = fio_backend();
        fio_net_send_cmd(server_fd, FIO_NET_CMD_START, &spdu, sizeof(spdu), 0);
 
        ret = fio_backend();
index 9bf8907f1b7d754fb7f35386be70a95ea787015c..624e4c0a49dfed37b9bd8e7f82304dcc4ad06a37 100644 (file)
--- a/server.h
+++ b/server.h
@@ -36,7 +36,7 @@ struct fio_net_int_cmd {
 };
 
 enum {
 };
 
 enum {
-       FIO_SERVER_VER          = 8,
+       FIO_SERVER_VER          = 9,
 
        FIO_SERVER_MAX_PDU      = 1024,
 
 
        FIO_SERVER_MAX_PDU      = 1024,
 
@@ -96,6 +96,7 @@ struct cmd_line_pdu {
 
 struct cmd_start_pdu {
        uint32_t jobs;
 
 struct cmd_start_pdu {
        uint32_t jobs;
+       uint32_t stat_outputs;
 };
 
 struct cmd_end_pdu {
 };
 
 struct cmd_end_pdu {