]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: improve the logic of the loop when doing bench test
authorPCzhangPC <pengcheng.zhang@easystack.cn>
Thu, 14 Sep 2017 05:26:43 +0000 (13:26 +0800)
committerPCzhangPC <pengcheng.zhang@easystack.cn>
Thu, 14 Sep 2017 05:26:43 +0000 (13:26 +0800)
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 <pengcheng.zhang@easystack.cn>
src/tools/rbd/action/Bench.cc

index 255aad032fe373aa9089460de07f47f2d16e7864..144e9d1dd0c188c3e30cb7568052836fbf85a958 100644 (file)
@@ -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 {