]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix thread_offsets calculation of rbd bench 20590/head
authorHitoshi Kamei <hitoshi.kamei.xm@hitachi.com>
Fri, 2 Mar 2018 11:14:04 +0000 (20:14 +0900)
committerHitoshi Kamei <hitoshi.kamei.xm@hitachi.com>
Fri, 2 Mar 2018 11:14:04 +0000 (20:14 +0900)
This patch fixes the calculation of the thread_offset vector
for sequential I/O of rbd bench command.

The rbd bench command doesn't access whole image of rbd,
because the some chunks are not assigned to threads.
This patch changes the way to calculate the thread_offsets
to assign all chunks to threads.

Signed-off-by: Hitoshi Kamei <hitoshi.kamei.xm@hitachi.com>
Cc: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
src/tools/rbd/action/Bench.cc

index 07b9f4002548b3a5419f44b8499511b3f7bc7fd7..95177d7a872660be82e39fa1f620aff21175c9a2 100644 (file)
@@ -276,6 +276,7 @@ int do_bench(librbd::Image& image, io_type_t io_type,
   int write_ops = 0;
 
   for (off = 0; off < io_bytes; ) {
+    // Issue I/O
     i = 0;
     while (i < io_threads && off < io_bytes) {
       bool read_flag = should_read(read_proportion);
@@ -283,13 +284,6 @@ int do_bench(librbd::Image& image, io_type_t io_type,
       b.wait_for(io_threads - 1);
       b.start_io(io_threads, thread_offset[i], io_size, op_flags, read_flag);
 
-      if (random) {
-        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;
-      }
       ++i;
       ++ios;
       off += io_size;
@@ -303,6 +297,22 @@ int do_bench(librbd::Image& image, io_type_t io_type,
         write_ops++;
     }
 
+    // Set the thread_offsets of next I/O
+    for (i = 0; i < io_threads; ++i) {
+      if (random) {
+        thread_offset[i] = (rand() % (size / io_size)) * io_size;
+        continue;
+      }
+      if (off < (io_size * unit_len * io_threads) ) {
+        thread_offset[i] += io_size;
+      } else {
+        // thread_offset is adjusted to the chunks unassigned to threads.
+        thread_offset[i] = off + (i * io_size);
+      }
+      if (thread_offset[i] + io_size > size)
+        thread_offset[i] = unit_len * i * io_size;
+    }
+
     coarse_mono_time now = coarse_mono_clock::now();
     chrono::duration<double> elapsed = now - start;
     if (last == chrono::duration<double>::zero()) {