From 918df9121362141567edd94e8b0dd6746cdb22a7 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 19 Oct 2017 10:37:01 -0400 Subject: [PATCH] rbd: bench should flush prior to starting a test 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 --- qa/workunits/rbd/journal.sh | 9 +++++---- src/tools/rbd/action/Bench.cc | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/qa/workunits/rbd/journal.sh b/qa/workunits/rbd/journal.sh index 34a7451ff3b3a..02a8ebd8c13fc 100755 --- a/qa/workunits/rbd/journal.sh +++ b/qa/workunits/rbd/journal.sh @@ -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) } ' diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 8e15a7dcf73e0..b6592bfda7305 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -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(); -- 2.39.5