]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: cache was not switching to writeback after first flush 10797/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 17 Aug 2016 16:08:37 +0000 (12:08 -0400)
committerMykola Golub <mgolub@mirantis.com>
Fri, 19 Aug 2016 19:59:07 +0000 (22:59 +0300)
Fixes: http://tracker.ceph.com/issues/16654
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 2d9840af39555ce00246b50e4a5c186798bd88ff)

src/librbd/AioImageRequest.cc
src/test/librbd/journal/test_Replay.cc
src/test/librbd/mock/MockImageCtx.h
src/test/librbd/test_mock_AioImageRequest.cc

index dd1e26aa49fe2a7b1ac5cc3410e10d272082a787..010283ff4016c7af63f5c8cff76bdba798e6d349 100644 (file)
@@ -563,6 +563,8 @@ void AioImageDiscard<I>::update_stats(size_t length) {
 template <typename I>
 void AioImageFlush<I>::send_request() {
   I &image_ctx = this->m_image_ctx;
+  image_ctx.user_flushed();
+
   bool journaling = false;
   {
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
index 361c6e0c7eafb6463531f322d4bd549b7f30cb4e..e5ff7490ab5b6e10bf7e1ad943f7c519dd8302bc 100644 (file)
@@ -687,6 +687,12 @@ TEST_F(TestJournalReplay, ObjectPosition) {
   ASSERT_EQ(0, aio_comp->wait_for_complete());
   aio_comp->release();
 
+  {
+    // user flush requests are ignored when journaling + cache are enabled
+    RWLock::RLocker owner_lock(ictx->owner_lock);
+    ictx->flush();
+  }
+
   // check the commit position updated
   get_journal_commit_position(ictx, &current_tag, &current_entry);
   ASSERT_EQ(initial_tag + 1, current_tag);
index 2818eb566dacf779d5b519317661b023e63f015a..ae0f3d67fbdcad7cd742d084a736190cdd61f251 100644 (file)
@@ -148,6 +148,7 @@ struct MockImageCtx {
                               uint8_t protection_status, uint64_t flags));
   MOCK_METHOD2(rm_snap, void(std::string in_snap_name, librados::snap_t id));
 
+  MOCK_METHOD0(user_flushed, void());
   MOCK_METHOD1(flush, void(Context *));
   MOCK_METHOD1(flush_async_operations, void(Context *));
   MOCK_METHOD1(flush_copyup, void(Context *));
index 2cd6b162a44084d6a307a0e48b884c4cf12f8af9..dd64b5f28a886547ee3ce008bd92ce16523d42bc 100644 (file)
@@ -169,6 +169,10 @@ struct TestMockAioImageRequest : public TestMockFixture {
                 }));
   }
 
+  void expect_user_flushed(MockImageCtx &mock_image_ctx) {
+    EXPECT_CALL(mock_image_ctx, user_flushed());
+  }
+
   void expect_flush(MockImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(mock_image_ctx, flush(_))
       .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
@@ -240,6 +244,7 @@ TEST_F(TestMockAioImageRequest, AioFlushJournalAppendDisabled) {
   mock_image_ctx.journal = &mock_journal;
 
   InSequence seq;
+  expect_user_flushed(mock_image_ctx);
   expect_is_journal_appending(mock_journal, false);
   expect_flush(mock_image_ctx, 0);