]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: bench should flush prior to starting a test 18403/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 19 Oct 2017 14:37:01 +0000 (10:37 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 23 Oct 2017 17:22:50 +0000 (13:22 -0400)
For the new read-based bench tests, flushing prior to the start of the test
will result in the exclusive lock being acquired and the object map being
utilized.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
qa/workunits/rbd/journal.sh
src/tools/rbd/action/Bench.cc

index 34a7451ff3b3a05ac1efe071a8db6e99d4e54830..02a8ebd8c13fcf3573f190ed04dddf3651974fab 100755 (executable)
@@ -96,16 +96,17 @@ test_rbd_journal()
     rbd snap create ${image1}@test
     restore_commit_position ${journal1}
     # check that commit position is properly updated: the journal should contain
-    # 12 entries (10 AioWrite + 1 SnapCreate + 1 OpFinish) and commit
-    # position set to tid=11
+    # 14 entries (2 AioFlush + 10 AioWrite + 1 SnapCreate + 1 OpFinish) and
+    # commit position set to tid=14
     rbd journal inspect --image ${image1} --verbose | awk '
+      /AioFlush/          {a++}         # match: "event_type": "AioFlush",
       /AioWrite/          {w++}         # match: "event_type": "AioWrite",
       /SnapCreate/        {s++}         # match: "event_type": "SnapCreate",
       /OpFinish/          {f++}         # match: "event_type": "OpFinish",
-      /entries inspected/ {t=$1; e=$4}  # match: 12 entries inspected, 0 errors
+      /entries inspected/ {t=$1; e=$4}  # match: 14 entries inspected, 0 errors
                           {print}       # for diagnostic
       END                 {
-        if (w != 10 || s != 1 || f != 1 || t != 12 || e != 0) exit(1)
+        if (a != 2 || w != 10 || s != 1 || f != 1 || t != 14 || e != 0) exit(1)
       }
     '
 
index 8e15a7dcf73e031eb92be58f8070967ccc2eb76c..b6592bfda73056a848b3b801b6fe403a1062a85a 100644 (file)
@@ -207,6 +207,12 @@ int do_bench(librbd::Image& image, io_type_t io_type,
     return -EINVAL;
   }
 
+  int r = image.flush();
+  if (r < 0 && (r != -EROFS || io_type != IO_TYPE_READ)) {
+    std::cerr << "rbd: failed to flush: " << cpp_strerror(r) << std::endl;
+    return r;
+  }
+
   rbd_bencher b(&image, io_type, io_size);
 
   std::cout << "bench "
@@ -316,10 +322,13 @@ int do_bench(librbd::Image& image, io_type_t io_type,
     }
   }
   b.wait_for(0);
-  int r = image.flush();
-  if (r < 0) {
-    std::cerr << "Error flushing data at the end: " << cpp_strerror(r)
-              << std::endl;
+
+  if (io_type != IO_TYPE_READ) {
+    r = image.flush();
+    if (r < 0) {
+      std::cerr << "rbd: failed to flush at the end: " << cpp_strerror(r)
+                << std::endl;
+    }
   }
 
   utime_t now = ceph_clock_now();