]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix rbd bench-write improper behavior 1006/head
authorHaomai Wang <haomaiwang@gmail.com>
Sat, 28 Dec 2013 09:57:43 +0000 (17:57 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Sat, 28 Dec 2013 10:33:37 +0000 (18:33 +0800)
"rbd bench-write" eject all write operations with the same offset at the same
time. It will result in non-objective performance result from this command.

fix #7066

Co-Author: Rongze Zhu <rongze@unitedstack.com>
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/rbd.cc

index 2e87b62664d85967f54bf691a8efa207c8f641ec..1cc792f2be01f386378139ce619a0277bc3106ea 100644 (file)
@@ -913,19 +913,34 @@ static int do_bench_write(librbd::Image& image, uint64_t io_size,
   uint64_t size = 0;
   image.size(&size);
 
+  vector<uint64_t> thread_offset;
+  uint64_t i;
+  uint64_t start_pos;
+
+  // disturb all thread's offset, used by seq write
+  for (i = 0; i < io_threads; i++) {
+    start_pos = (rand() % (size / io_size)) * io_size;
+    thread_offset.push_back(start_pos);
+  }
+
   printf("  SEC       OPS   OPS/SEC   BYTES/SEC\n");
   uint64_t off;
   for (off = 0; off < io_bytes; off += io_size) {
     b.wait_for(io_threads - 1);
-    uint64_t i = 0;
-    uint64_t real_off = off;
-    if (pattern == "rand") {
-      real_off = (rand() % (size / io_size)) * io_size;
-    }
-    while (i < io_threads &&
-          b.start_write(io_threads, real_off, io_size, bl)) {
+    i = 0;
+    while (i < io_threads && off < io_bytes &&
+          b.start_write(io_threads, thread_offset[i], io_size, bl)) {
       ++i;
       ++ios;
+      off += io_size;
+
+      if (pattern == "rand") {
+        thread_offset[i] = (rand() % (size / io_size)) * io_size;
+      } else {
+        thread_offset[i] += io_size;
+        if (thread_offset[i] + io_size > size)
+          thread_offset[i] = 0;
+      }
     }
 
     utime_t now = ceph_clock_now(NULL);