]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix bench-write infinite loop
authorJosh Durgin <josh.durgin@inktank.com>
Wed, 26 Dec 2012 22:24:22 +0000 (14:24 -0800)
committerSage Weil <sage@inktank.com>
Sun, 27 Jan 2013 09:28:11 +0000 (01:28 -0800)
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 <josh.durgin@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage.weil@inktank.com>
(cherry picked from commit d81ac8418f9e6bbc9adcc69b2e7cb98dd4db6abb)

src/rbd.cc

index 9aaca568208cb2a767a54513c55b18c0a500b2da..e6b0d32c4209af173ec9aa2dd0575f9ea4a9a9b4 100644 (file)
@@ -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;