From: Josh Durgin Date: Wed, 26 Dec 2012 22:24:22 +0000 (-0800) Subject: rbd: fix bench-write infinite loop X-Git-Tag: v0.56.2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a16c6f3dc278e19e66776ffde45de3ff0db46a6c;p=ceph.git rbd: fix bench-write infinite loop I/O was continously submitted as long as there were few enough ops in flight. If the number of 'threads' was high, or caching was turned on, there would never be that many ops in flight, so the loop would continue indefinitely. Instead, submit at most io_threads ops per offset. Fixes: #3413 Signed-off-by: Josh Durgin Reviewed-by: Dan Mick Reviewed-by: Sage Weil (cherry picked from commit d81ac8418f9e6bbc9adcc69b2e7cb98dd4db6abb) --- diff --git a/src/rbd.cc b/src/rbd.cc index 9aaca568208c..e6b0d32c4209 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -598,12 +598,16 @@ struct rbd_bencher { in_flight(0) { } - bool start_write(int max, uint64_t off, uint64_t len, bufferlist& bl) { - Mutex::Locker l(lock); - if (in_flight >= max) - return false; - in_flight++; - librbd::RBD::AioCompletion *c = new librbd::RBD::AioCompletion((void *)this, rbd_bencher_completion); + bool start_write(int max, uint64_t off, uint64_t len, bufferlist& bl) + { + { + Mutex::Locker l(lock); + if (in_flight >= max) + return false; + in_flight++; + } + librbd::RBD::AioCompletion *c = + new librbd::RBD::AioCompletion((void *)this, rbd_bencher_completion); image->aio_write(off, len, bl, c); //cout << "start " << c << " at " << off << "~" << len << std::endl; return true; @@ -655,8 +659,12 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, uint64_t io_th uint64_t off; for (off = 0; off < io_bytes; off += io_size) { b.wait_for(io_threads - 1); - while (b.start_write(io_threads, off, io_size, bl)) - ios++; + uint64_t i = 0; + while (i < io_threads && + b.start_write(io_threads, off, io_size, bl)) { + ++i; + ++ios; + } utime_t now = ceph_clock_now(NULL); utime_t elapsed = now - start; @@ -668,6 +676,10 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size, uint64_t io_th } } b.wait_for(0); + int r = image.flush(); + if (r < 0) { + cerr << "Error flushing data at the end: " << cpp_strerror(r) << std::endl; + } utime_t now = ceph_clock_now(NULL); double elapsed = now - start;