fio: Fix padding properly
authorGwendal Grignou <gwendal@chromium.org>
Sat, 25 Oct 2014 23:04:32 +0000 (16:04 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 27 Oct 2014 14:50:47 +0000 (08:50 -0600)
Completely fix padding:
- use anonymous union for padding.
- move existing padding in thread_stat.
- add alignment checks.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
libfio.c
stat.h

index b823bd4779bfed19b1ae0c544a52eb79f17ebcd6..1abf39a84edff09b4cdf571361c6356d7706641f 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -305,6 +305,8 @@ int initialize_fio(char *envp[])
         * access (ARM).
         */
        compiletime_assert((offsetof(struct thread_stat, percentile_list) % 8) == 0, "stat percentile_list");
+       compiletime_assert((offsetof(struct thread_stat, total_run_time) % 8) == 0, "total_run_time");
+       compiletime_assert((offsetof(struct thread_stat, total_err_count) % 8) == 0, "total_err_count");
        compiletime_assert((offsetof(struct thread_stat, latency_percentile) % 8) == 0, "stat latency_percentile");
        compiletime_assert((offsetof(struct thread_options_pack, zipf_theta) % 8) == 0, "zipf_theta");
        compiletime_assert((offsetof(struct thread_options_pack, pareto_h) % 8) == 0, "pareto_h");
diff --git a/stat.h b/stat.h
index 16b3d1a681b1c261e5a408e90e3303602e5175c6..8aefe03c65099f2f9e157efe7718fc1f9314cef2 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -158,6 +158,8 @@ struct thread_stat {
        uint32_t io_u_lat_u[FIO_IO_U_LAT_U_NR];
        uint32_t io_u_lat_m[FIO_IO_U_LAT_M_NR];
        uint32_t io_u_plat[DDIR_RWDIR_CNT][FIO_IO_U_PLAT_NR];
+       uint32_t pad;
+
        uint64_t total_io_u[3];
        uint64_t short_io_u[3];
        uint64_t drop_io_u[3];
@@ -171,8 +173,10 @@ struct thread_stat {
        /*
         * IO Error related stats
         */
-       uint16_t continue_on_error;
-       uint16_t filler[3];
+       union {
+               uint16_t continue_on_error;
+               uint64_t pad2;
+       };
        uint64_t total_err_count;
        uint32_t first_error;
 
@@ -181,7 +185,6 @@ struct thread_stat {
 
        uint32_t latency_depth;
        uint64_t latency_target;
-       uint32_t pad;
        fio_fp64_t latency_percentile;
        uint64_t latency_window;
 } __attribute__((packed));