From 333f3a01a9916c781f266078391c580efb81a0fc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 18 Aug 2015 16:05:29 -0400 Subject: [PATCH] rbd: fix bench-write Make each IO get a unique offset! Signed-off-by: Sage Weil --- src/rbd.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rbd.cc b/src/rbd.cc index f8eedb02ff357..79a7a04f8a470 100755 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -1049,15 +1049,7 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, for (off = 0; off < io_bytes; ) { b.wait_for(io_threads - 1); i = 0; - while (i < io_threads && off < io_bytes && - b.start_write(io_threads, thread_offset[i], io_size, bl, op_flags)) { - ++i; - ++ios; - off += io_size; - - ++cur_ios; - cur_off += io_size; - + while (i < io_threads && off < io_bytes) { if (pattern == "rand") { thread_offset[i] = (rand() % (size / io_size)) * io_size; } else { @@ -1065,6 +1057,16 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, if (thread_offset[i] + io_size > size) thread_offset[i] = 0; } + + if (!b.start_write(io_threads, thread_offset[i], io_size, bl, op_flags)) + break; + + ++i; + ++ios; + off += io_size; + + ++cur_ios; + cur_off += io_size; } utime_t now = ceph_clock_now(NULL); -- 2.39.5