Scale bw output to MB/sec if larger than 99999 KB/sec
[fio.git] / client.c
index 31b4862775eb159775d2fa784a28a9032cc600f6..c72f034a429a5b5da2120082d9e9c89d802c5fdb 100644 (file)
--- a/client.c
+++ b/client.c
@@ -41,6 +41,7 @@ struct fio_client {
 
        int skip_newline;
        int is_sock;
+       int disk_stats_shown;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
@@ -601,6 +602,54 @@ static void handle_gs(struct fio_net_cmd *cmd)
        show_group_stats(gs);
 }
 
+static void convert_agg(struct disk_util_agg *agg)
+{
+       int i;
+
+       for (i = 0; i < 2; i++) {
+               agg->ios[i]     = le32_to_cpu(agg->ios[i]);
+               agg->merges[i]  = le32_to_cpu(agg->merges[i]);
+               agg->sectors[i] = le64_to_cpu(agg->sectors[i]);
+               agg->ticks[i]   = le32_to_cpu(agg->ticks[i]);
+       }
+
+       agg->io_ticks           = le32_to_cpu(agg->io_ticks);
+       agg->time_in_queue      = le32_to_cpu(agg->time_in_queue);
+       agg->slavecount         = le32_to_cpu(agg->slavecount);
+       agg->max_util.u.f       = __le64_to_cpu(fio_uint64_to_double(agg->max_util.u.i));
+}
+
+static void convert_dus(struct disk_util_stat *dus)
+{
+       int i;
+
+       for (i = 0; i < 2; i++) {
+               dus->ios[i]     = le32_to_cpu(dus->ios[i]);
+               dus->merges[i]  = le32_to_cpu(dus->merges[i]);
+               dus->sectors[i] = le64_to_cpu(dus->sectors[i]);
+               dus->ticks[i]   = le32_to_cpu(dus->ticks[i]);
+       }
+
+       dus->io_ticks           = le32_to_cpu(dus->io_ticks);
+       dus->time_in_queue      = le32_to_cpu(dus->time_in_queue);
+       dus->msec               = le64_to_cpu(dus->msec);
+}
+
+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");
+       }
+
+       print_disk_util(&du->dus, &du->agg, terse_output);
+}
+
 static void convert_jobs_eta(struct jobs_eta *je)
 {
        int i;
@@ -663,7 +712,7 @@ static void remove_reply_cmd(struct fio_client *client, struct fio_net_cmd *cmd)
        flist_for_each(entry, &client->cmd_list) {
                icmd = flist_entry(entry, struct fio_net_int_cmd, list);
 
-               if (cmd->tag == (uint64_t) icmd)
+               if (cmd->tag == (uintptr_t) icmd)
                        break;
 
                icmd = NULL;
@@ -682,7 +731,7 @@ static void remove_reply_cmd(struct fio_client *client, struct fio_net_cmd *cmd)
 static void handle_eta(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
-       struct client_eta *eta = (struct client_eta *) cmd->tag;
+       struct client_eta *eta = (struct client_eta *) (uintptr_t) cmd->tag;
 
        dprint(FD_NET, "client: got eta tag %p, %d\n", eta, eta->pending);
 
@@ -700,6 +749,7 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
        const char *os, *arch;
+       char bit[16];
 
        os = fio_get_os_string(probe->os);
        if (!os)
@@ -709,9 +759,11 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
        if (!arch)
                os = "unknown";
 
-       log_info("hostname=%s, be=%u, os=%s, arch=%s, fio=%u.%u.%u\n",
-               probe->hostname, probe->bigendian, os, arch, probe->fio_major,
-               probe->fio_minor, probe->fio_patch);
+       sprintf(bit, "%d-bit", probe->bpp * 8);
+
+       log_info("hostname=%s, be=%u, %s, os=%s, arch=%s, fio=%u.%u.%u\n",
+               probe->hostname, probe->bigendian, bit, os, arch,
+               probe->fio_major, probe->fio_minor, probe->fio_patch);
 
        if (!client->name)
                client->name = strdup((char *) probe->hostname);
@@ -750,6 +802,10 @@ static int handle_client(struct fio_client *client)
                free(cmd);
                break;
                }
+       case FIO_NET_CMD_DU:
+               handle_du(client, cmd);
+               free(cmd);
+               break;
        case FIO_NET_CMD_TS:
                handle_ts(cmd);
                free(cmd);
@@ -810,7 +866,7 @@ static void request_client_etas(void)
                flist_add_tail(&client->eta_list, &eta_list);
                client->eta_in_flight = eta;
                fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_SEND_ETA,
-                                       (uint64_t) eta, &client->cmd_list);
+                                       (uintptr_t) eta, &client->cmd_list);
        }
 
        while (skipped--)