From: PCzhangPC Date: Thu, 14 Sep 2017 05:26:43 +0000 (+0800) Subject: rbd: improve the logic of the loop when doing bench test X-Git-Tag: v13.0.1~694^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=021eb15ae93ed1ff776948437e1bfa9ef31bc5d4;p=ceph.git rbd: improve the logic of the loop when doing bench test when we do rbd bench test, there's two problems: 1. do lots of failure start_io try 2. The number of executions of each thread is unevenly distributed this commit is trying to fix this. Signed-off-by: PCzhangPC --- diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 255aad032fe..144e9d1dd0c 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -125,12 +125,10 @@ struct rbd_bencher { } - bool start_io(int max, uint64_t off, uint64_t len, int op_flags) + void start_io(int max, uint64_t off, uint64_t len, int op_flags) { { Mutex::Locker l(lock); - if (in_flight >= max) - return false; in_flight++; } @@ -147,8 +145,6 @@ struct rbd_bencher { } else { assert(0 == "Invalid io_type"); } - //cout << "start " << c << " at " << off << "~" << len << std::endl; - return true; } void wait_for(int max) { @@ -255,13 +251,13 @@ int do_bench(librbd::Image& image, io_type_t io_type, printf(" SEC OPS OPS/SEC BYTES/SEC\n"); uint64_t off; + for (off = 0; off < io_bytes; ) { - b.wait_for(io_threads - 1); i = 0; while (i < io_threads && off < io_bytes) { - if (!b.start_io(io_threads, thread_offset[i], io_size, op_flags)) { - break; - } + b.wait_for(io_threads - 1); + b.start_io(io_threads, thread_offset[i], io_size, op_flags); + if (random) { thread_offset[i] = (rand() % (size / io_size)) * io_size; } else {