From: Jens Axboe Date: Sat, 3 Mar 2012 19:35:50 +0000 (+0100) Subject: Convert net commands in the generic command handler X-Git-Tag: gfio-0.1~274 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=3bf236c082e36f222b64edf9ae2bd7637156d0ac;p=fio.git Convert net commands in the generic command handler Removes this from the cli/gui client, it can be handled generically. Signed-off-by: Jens Axboe --- diff --git a/client.c b/client.c index ff3983bd..1c609b6b 100644 --- a/client.c +++ b/client.c @@ -623,9 +623,6 @@ static void handle_ts(struct fio_net_cmd *cmd) { struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload; - convert_ts(&p->ts, &p->ts); - convert_gs(&p->rs, &p->rs); - show_thread_status(&p->ts, &p->rs); if (sum_stat_clients == 1) @@ -647,10 +644,25 @@ static void handle_gs(struct fio_net_cmd *cmd) { struct group_run_stats *gs = (struct group_run_stats *) cmd->payload; - convert_gs(gs, gs); show_group_stats(gs); } +static void handle_text(struct fio_client *client, struct fio_net_cmd *cmd) +{ + struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmd->payload; + const char *buf = (const char *) pdu->buf; + const char *name; + int fio_unused ret; + + name = client->name ? client->name : client->hostname; + + if (!client->skip_newline) + fprintf(f_out, "<%s> ", name); + ret = fwrite(buf, pdu->buf_len, 1, f_out); + fflush(f_out); + client->skip_newline = strchr(buf, '\n') == NULL; +} + static void convert_agg(struct disk_util_agg *agg) { int i; @@ -684,30 +696,10 @@ static void convert_dus(struct disk_util_stat *dus) dus->msec = le64_to_cpu(dus->msec); } -static void handle_text(struct fio_client *client, struct fio_net_cmd *cmd) -{ - struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmd->payload; - const char *buf = (const char *) pdu->buf; - const char *name; - int fio_unused ret; - - name = client->name ? client->name : client->hostname; - - if (!client->skip_newline) - fprintf(f_out, "<%s> ", name); - ret = fwrite(buf, pdu->buf_len, 1, f_out); - fflush(f_out); - client->skip_newline = strchr(buf, '\n') == NULL; -} - - static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd) { struct cmd_du_pdu *du = (struct cmd_du_pdu *) cmd->payload; - convert_dus(&du->dus); - convert_agg(&du->agg); - if (!client->disk_stats_shown) { client->disk_stats_shown = 1; log_info("\nDisk stats (read/write):\n"); @@ -716,7 +708,7 @@ static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd) print_disk_util(&du->dus, &du->agg, terse_output); } -void fio_client_convert_jobs_eta(struct jobs_eta *je) +static void convert_jobs_eta(struct jobs_eta *je) { int i; @@ -806,7 +798,6 @@ static void handle_eta(struct fio_client *client, struct fio_net_cmd *cmd) client->eta_in_flight = NULL; flist_del_init(&client->eta_list); - fio_client_convert_jobs_eta(je); fio_client_sum_jobs_eta(&eta->eta, je); fio_client_dec_jobs_eta(eta, display_thread_status); } @@ -889,23 +880,44 @@ int fio_handle_client(struct fio_client *client, struct client_ops *ops) ops->text_op(client, cmd); free(cmd); break; - case FIO_NET_CMD_DU: + case FIO_NET_CMD_DU: { + struct cmd_du_pdu *du = (struct cmd_du_pdu *) cmd->payload; + + convert_dus(&du->dus); + convert_agg(&du->agg); + ops->disk_util(client, cmd); free(cmd); break; - case FIO_NET_CMD_TS: + } + case FIO_NET_CMD_TS: { + struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload; + + convert_ts(&p->ts, &p->ts); + convert_gs(&p->rs, &p->rs); + ops->thread_status(cmd); free(cmd); break; - case FIO_NET_CMD_GS: + } + case FIO_NET_CMD_GS: { + struct group_run_stats *gs = (struct group_run_stats *) cmd->payload; + + convert_gs(gs, gs); + ops->group_stats(cmd); free(cmd); break; - case FIO_NET_CMD_ETA: + } + case FIO_NET_CMD_ETA: { + struct jobs_eta *je = (struct jobs_eta *) cmd->payload; + remove_reply_cmd(client, cmd); + convert_jobs_eta(je); ops->eta(client, cmd); free(cmd); break; + } case FIO_NET_CMD_PROBE: remove_reply_cmd(client, cmd); ops->probe(client, cmd); diff --git a/client.h b/client.h index 7ab4c83a..532a33a4 100644 --- a/client.h +++ b/client.h @@ -80,7 +80,6 @@ struct client_eta { extern int fio_handle_client(struct fio_client *, struct client_ops *ops); extern void fio_client_dec_jobs_eta(struct client_eta *eta, void (*fn)(struct jobs_eta *)); extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); -extern void fio_client_convert_jobs_eta(struct jobs_eta *je); enum { Fio_client_ipv4 = 1, diff --git a/gfio.c b/gfio.c index 32e012e7..ac7200ac 100644 --- a/gfio.c +++ b/gfio.c @@ -254,7 +254,6 @@ static void gfio_eta_op(struct fio_client *client, struct fio_net_cmd *cmd) client->eta_in_flight = NULL; flist_del_init(&client->eta_list); - fio_client_convert_jobs_eta(je); fio_client_sum_jobs_eta(&eta->eta, je); fio_client_dec_jobs_eta(eta, gfio_update_eta); }