diskutil: separate out stats from name
authorJens Axboe <axboe@fb.com>
Fri, 11 Apr 2014 18:17:53 +0000 (12:17 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 11 Apr 2014 18:17:53 +0000 (12:17 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
client.c
diskutil.c
diskutil.h
server.c

index 467d093..05439e1 100644 (file)
--- a/client.c
+++ b/client.c
@@ -907,15 +907,15 @@ 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->s.ios[i]           = le32_to_cpu(dus->s.ios[i]);
+               dus->s.merges[i]        = le32_to_cpu(dus->s.merges[i]);
+               dus->s.sectors[i]       = le64_to_cpu(dus->s.sectors[i]);
+               dus->s.ticks[i]         = le32_to_cpu(dus->s.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);
+       dus->s.io_ticks         = le32_to_cpu(dus->s.io_ticks);
+       dus->s.time_in_queue    = le32_to_cpu(dus->s.time_in_queue);
+       dus->s.msec             = le64_to_cpu(dus->s.msec);
 }
 
 static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd)
index 1b4accb..d97c5ca 100644 (file)
@@ -61,16 +61,18 @@ static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)
 
        dprint(FD_DISKUTIL, "%s: %s", du->path, p);
 
-       ret = sscanf(p, "%u %u %llu %u %u %u %llu %u %u %u %u\n", &dus->ios[0],
-                                       &dus->merges[0], &sectors[0],
-                                       &dus->ticks[0], &dus->ios[1],
-                                       &dus->merges[1], &sectors[1],
-                                       &dus->ticks[1], &in_flight,
-                                       &dus->io_ticks, &dus->time_in_queue);
+       ret = sscanf(p, "%u %u %llu %u %u %u %llu %u %u %u %u\n",
+                                       &dus->s.ios[0],
+                                       &dus->s.merges[0], &sectors[0],
+                                       &dus->s.ticks[0], &dus->s.ios[1],
+                                       &dus->s.merges[1], &sectors[1],
+                                       &dus->s.ticks[1], &in_flight,
+                                       &dus->s.io_ticks,
+                                       &dus->s.time_in_queue);
        fclose(f);
        dprint(FD_DISKUTIL, "%s: stat read ok? %d\n", du->path, ret == 1);
-       dus->sectors[0] = sectors[0];
-       dus->sectors[1] = sectors[1];
+       dus->s.sectors[0] = sectors[0];
+       dus->s.sectors[1] = sectors[1];
        return ret != 11;
 }
 
@@ -87,21 +89,21 @@ static void update_io_tick_disk(struct disk_util *du)
        dus = &du->dus;
        ldus = &du->last_dus;
 
-       dus->sectors[0] += (__dus.sectors[0] - ldus->sectors[0]);
-       dus->sectors[1] += (__dus.sectors[1] - ldus->sectors[1]);
-       dus->ios[0] += (__dus.ios[0] - ldus->ios[0]);
-       dus->ios[1] += (__dus.ios[1] - ldus->ios[1]);
-       dus->merges[0] += (__dus.merges[0] - ldus->merges[0]);
-       dus->merges[1] += (__dus.merges[1] - ldus->merges[1]);
-       dus->ticks[0] += (__dus.ticks[0] - ldus->ticks[0]);
-       dus->ticks[1] += (__dus.ticks[1] - ldus->ticks[1]);
-       dus->io_ticks += (__dus.io_ticks - ldus->io_ticks);
-       dus->time_in_queue += (__dus.time_in_queue - ldus->time_in_queue);
+       dus->s.sectors[0] += (__dus.s.sectors[0] - ldus->s.sectors[0]);
+       dus->s.sectors[1] += (__dus.s.sectors[1] - ldus->s.sectors[1]);
+       dus->s.ios[0] += (__dus.s.ios[0] - ldus->s.ios[0]);
+       dus->s.ios[1] += (__dus.s.ios[1] - ldus->s.ios[1]);
+       dus->s.merges[0] += (__dus.s.merges[0] - ldus->s.merges[0]);
+       dus->s.merges[1] += (__dus.s.merges[1] - ldus->s.merges[1]);
+       dus->s.ticks[0] += (__dus.s.ticks[0] - ldus->s.ticks[0]);
+       dus->s.ticks[1] += (__dus.s.ticks[1] - ldus->s.ticks[1]);
+       dus->s.io_ticks += (__dus.s.io_ticks - ldus->s.io_ticks);
+       dus->s.time_in_queue += (__dus.s.time_in_queue - ldus->s.time_in_queue);
 
        fio_gettime(&t, NULL);
-       dus->msec += mtime_since(&du->time, &t);
+       dus->s.msec += mtime_since(&du->time, &t);
        memcpy(&du->time, &t, sizeof(t));
-       memcpy(ldus, &__dus, sizeof(__dus));
+       memcpy(&ldus->s, &__dus.s, sizeof(__dus.s));
 }
 
 int update_io_ticks(void)
@@ -528,18 +530,18 @@ static void aggregate_slaves_stats(struct disk_util *masterdu)
        flist_for_each(entry, &masterdu->slaves) {
                slavedu = flist_entry(entry, struct disk_util, slavelist);
                dus = &slavedu->dus;
-               agg->ios[0] += dus->ios[0];
-               agg->ios[1] += dus->ios[1];
-               agg->merges[0] += dus->merges[0];
-               agg->merges[1] += dus->merges[1];
-               agg->sectors[0] += dus->sectors[0];
-               agg->sectors[1] += dus->sectors[1];
-               agg->ticks[0] += dus->ticks[0];
-               agg->ticks[1] += dus->ticks[1];
-               agg->time_in_queue += dus->time_in_queue;
+               agg->ios[0] += dus->s.ios[0];
+               agg->ios[1] += dus->s.ios[1];
+               agg->merges[0] += dus->s.merges[0];
+               agg->merges[1] += dus->s.merges[1];
+               agg->sectors[0] += dus->s.sectors[0];
+               agg->sectors[1] += dus->s.sectors[1];
+               agg->ticks[0] += dus->s.ticks[0];
+               agg->ticks[1] += dus->s.ticks[1];
+               agg->time_in_queue += dus->s.time_in_queue;
                agg->slavecount++;
 
-               util = (double) (100 * dus->io_ticks / (double) slavedu->dus.msec);
+               util = (double) (100 * dus->s.io_ticks / (double) slavedu->dus.s.msec);
                /* System utilization is the utilization of the
                 * component with the highest utilization.
                 */
@@ -574,8 +576,8 @@ void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
 {
        double util = 0;
 
-       if (dus->msec)
-               util = (double) 100 * dus->io_ticks / (double) dus->msec;
+       if (dus->s.msec)
+               util = (double) 100 * dus->s.io_ticks / (double) dus->s.msec;
        if (util > 100.0)
                util = 100.0;
 
@@ -585,16 +587,17 @@ void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
 
                log_info("  %s: ios=%u/%u, merge=%u/%u, ticks=%u/%u, "
                         "in_queue=%u, util=%3.2f%%", dus->name,
-                                       dus->ios[0], dus->ios[1],
-                                       dus->merges[0], dus->merges[1],
-                                       dus->ticks[0], dus->ticks[1],
-                                       dus->time_in_queue, util);
+                                       dus->s.ios[0], dus->s.ios[1],
+                                       dus->s.merges[0], dus->s.merges[1],
+                                       dus->s.ticks[0], dus->s.ticks[1],
+                                       dus->s.time_in_queue, util);
        } else {
                log_info(";%s;%u;%u;%u;%u;%u;%u;%u;%3.2f%%",
-                                       dus->name, dus->ios[0], dus->ios[1],
-                                       dus->merges[0], dus->merges[1],
-                                       dus->ticks[0], dus->ticks[1],
-                                       dus->time_in_queue, util);
+                                       dus->name, dus->s.ios[0],
+                                       dus->s.ios[1], dus->s.merges[0],
+                                       dus->s.merges[1], dus->s.ticks[0],
+                                       dus->s.ticks[1],
+                                       dus->s.time_in_queue, util);
        }
 
        /*
@@ -613,8 +616,8 @@ void json_array_add_disk_util(struct disk_util_stat *dus,
        struct json_object *obj;
        double util = 0;
 
-       if (dus->msec)
-               util = (double) 100 * dus->io_ticks / (double) dus->msec;
+       if (dus->s.msec)
+               util = (double) 100 * dus->s.io_ticks / (double) dus->s.msec;
        if (util > 100.0)
                util = 100.0;
 
@@ -622,13 +625,13 @@ void json_array_add_disk_util(struct disk_util_stat *dus,
        json_array_add_value_object(array, obj);
 
        json_object_add_value_string(obj, "name", dus->name);
-       json_object_add_value_int(obj, "read_ios", dus->ios[0]);
-       json_object_add_value_int(obj, "write_ios", dus->ios[1]);
-       json_object_add_value_int(obj, "read_merges", dus->merges[0]);
-       json_object_add_value_int(obj, "write_merges", dus->merges[1]);
-       json_object_add_value_int(obj, "read_ticks", dus->ticks[0]);
-       json_object_add_value_int(obj, "write_ticks", dus->ticks[1]);
-       json_object_add_value_int(obj, "in_queue", dus->time_in_queue);
+       json_object_add_value_int(obj, "read_ios", dus->s.ios[0]);
+       json_object_add_value_int(obj, "write_ios", dus->s.ios[1]);
+       json_object_add_value_int(obj, "read_merges", dus->s.merges[0]);
+       json_object_add_value_int(obj, "write_merges", dus->s.merges[1]);
+       json_object_add_value_int(obj, "read_ticks", dus->s.ticks[0]);
+       json_object_add_value_int(obj, "write_ticks", dus->s.ticks[1]);
+       json_object_add_value_int(obj, "in_queue", dus->s.time_in_queue);
        json_object_add_value_float(obj, "util", util);
 
        /*
index 7207c73..d86e4ec 100644 (file)
@@ -5,11 +5,7 @@
 
 extern volatile int disk_util_exit;
 
-/*
- * Disk utils as read in /sys/block/<dev>/stat
- */
-struct disk_util_stat {
-       uint8_t name[FIO_DU_NAME_SZ];
+struct disk_util_stats {
        uint32_t ios[2];
        uint32_t merges[2];
        uint64_t sectors[2];
@@ -19,6 +15,14 @@ struct disk_util_stat {
        uint64_t msec;
 };
 
+/*
+ * Disk utils as read in /sys/block/<dev>/stat
+ */
+struct disk_util_stat {
+       uint8_t name[FIO_DU_NAME_SZ];
+       struct disk_util_stats s;
+};
+
 struct disk_util_agg {
        uint32_t ios[2];
        uint32_t merges[2];
index 73866d7..3346445 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1098,15 +1098,15 @@ static void convert_dus(struct disk_util_stat *dst, struct disk_util_stat *src)
        strcpy((char *) dst->name, (char *) src->name);
 
        for (i = 0; i < 2; i++) {
-               dst->ios[i]     = cpu_to_le32(src->ios[i]);
-               dst->merges[i]  = cpu_to_le32(src->merges[i]);
-               dst->sectors[i] = cpu_to_le64(src->sectors[i]);
-               dst->ticks[i]   = cpu_to_le32(src->ticks[i]);
+               dst->s.ios[i]           = cpu_to_le32(src->s.ios[i]);
+               dst->s.merges[i]        = cpu_to_le32(src->s.merges[i]);
+               dst->s.sectors[i]       = cpu_to_le64(src->s.sectors[i]);
+               dst->s.ticks[i]         = cpu_to_le32(src->s.ticks[i]);
        }
 
-       dst->io_ticks           = cpu_to_le32(src->io_ticks);
-       dst->time_in_queue      = cpu_to_le32(src->time_in_queue);
-       dst->msec               = cpu_to_le64(src->msec);
+       dst->s.io_ticks         = cpu_to_le32(src->s.io_ticks);
+       dst->s.time_in_queue    = cpu_to_le32(src->s.time_in_queue);
+       dst->s.msec             = cpu_to_le64(src->s.msec);
 }
 
 void fio_server_send_du(void)