fixed the error=invalid argument when the lower bound of bsrange is not power of 2.
authorPan Liu <liupan1111@gmail.com>
Fri, 17 Mar 2017 16:24:09 +0000 (00:24 +0800)
committerPan Liu <liupan1111@gmail.com>
Fri, 17 Mar 2017 16:24:09 +0000 (00:24 +0800)
Signed-off-by: Pan Liu <liupan1111@gmail.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index f6efae056ec0cff552f2ac038cb770ad8ea948aa..ab0f138313cddad030e7b0747febedf6777ca2c5 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 = 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;