From: Jens Axboe Date: Wed, 14 Nov 2012 20:09:45 +0000 (-0700) Subject: client/server: fixup "All clients" reporting X-Git-Tag: fio-2.0.11~7 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=108fea772db5f1dd91e2fb67737e3e0d36827b76 client/server: fixup "All clients" reporting We didn't properly account for no group_reporting and multiple jobs on multiple connections. Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index fd73eda0..b80c9038 100644 --- 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; +unsigned int stat_number = 0; unsigned int nr_process = 0; unsigned int nr_thread = 0; int shm_id = 0; diff --git a/client.c b/client.c index bf09d7ef..a4839130 100644 --- a/client.c +++ b/client.c @@ -47,9 +47,11 @@ struct fio_client { int is_sock; int disk_stats_shown; unsigned int jobs; + unsigned int nr_stat; int error; int ipv6; int sent_job; + int did_stat; 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 int sum_stat_clients; +static int sum_stat_clients = 0; 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) @@ -159,9 +162,11 @@ static void remove_client(struct fio_client *client) if (client->ini_file) free(client->ini_file); + if (!client->did_stat) + sum_stat_clients -= client->nr_stat; + free(client); nr_clients--; - sum_stat_clients--; } 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); } -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; @@ -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); + 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); @@ -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->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) @@ -921,7 +933,7 @@ static int handle_client(struct fio_client *client) free(cmd); break; case FIO_NET_CMD_TS: - handle_ts(cmd); + handle_ts(client, cmd); free(cmd); break; case FIO_NET_CMD_GS: @@ -1053,7 +1065,6 @@ int fio_handle_clients(void) pfds = malloc(nr_clients * sizeof(struct pollfd)); - sum_stat_clients = nr_clients; init_thread_stat(&client_ts); init_group_run_stat(&client_gs); diff --git a/fio.h b/fio.h index ca1a5f06..f69de0d3 100644 --- a/fio.h +++ b/fio.h @@ -558,6 +558,7 @@ enum { 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; diff --git a/init.c b/init.c index 23be8631..a682423e 100644 --- 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; + + if (!parent || !parent->o.group_reporting) + stat_number++; + return td; } diff --git a/server.c b/server.c index 72def7e0..33b80d68 100644 --- 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; + stat_number = 0; + 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(); diff --git a/server.h b/server.h index 9bf8907f..624e4c0a 100644 --- a/server.h +++ b/server.h @@ -36,7 +36,7 @@ struct fio_net_int_cmd { }; enum { - FIO_SERVER_VER = 8, + FIO_SERVER_VER = 9, FIO_SERVER_MAX_PDU = 1024, @@ -96,6 +96,7 @@ struct cmd_line_pdu { struct cmd_start_pdu { uint32_t jobs; + uint32_t stat_outputs; }; struct cmd_end_pdu {