From 17a6b702f221372c919459d7f3fd3a111673403f Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Sat, 18 Mar 2017 00:24:09 +0800 Subject: [PATCH] fixed the error=invalid argument when the lower bound of bsrange is not power of 2. Signed-off-by: Pan Liu --- io_u.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/io_u.c b/io_u.c index f6efae05..ab0f1383 100644 --- 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 = false; 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; -- 2.25.1