Merge branch 'wip-fix-bs-title' of https://github.com/liupan1111/fio
authorJens Axboe <axboe@fb.com>
Mon, 20 Mar 2017 01:49:04 +0000 (19:49 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 20 Mar 2017 01:49:04 +0000 (19:49 -0600)
io_u.c
lib/pow2.h

diff --git a/io_u.c b/io_u.c
index f6efae056ec0cff552f2ac038cb770ad8ea948aa..5f01c1b674ebecd8612c9681411dc9773dd5a493 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -533,6 +533,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
        unsigned int buflen = 0;
        unsigned int minbs, maxbs;
        uint64_t frand_max, r;
+       bool power_2;
 
        assert(ddir_rw(ddir));
 
@@ -577,9 +578,11 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
                        }
                }
 
-               if (!td->o.bs_unaligned && is_power_of_2(minbs))
+               power_2 = is_power_of_2(minbs);
+               if (!td->o.bs_unaligned && power_2)
                        buflen &= ~(minbs - 1);
-
+               else if (!td->o.bs_unaligned && !power_2) 
+                       buflen -= buflen % minbs; 
        } while (!io_u_fits(td, io_u, buflen));
 
        return buflen;
index f3ca4d7b86c2213fd4d33901c1aff09a26260b69..2cbca1ab3484d55757e9c1785a5459d674d5328c 100644 (file)
@@ -2,8 +2,9 @@
 #define FIO_POW2_H
 
 #include <inttypes.h>
+#include "types.h"
 
-static inline int is_power_of_2(uint64_t val)
+static inline bool is_power_of_2(uint64_t val)
 {
        return (val != 0 && ((val & (val - 1)) == 0));
 }