]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/librbd/test_mock_ExclusiveLock.cc
update sources to v12.1.1
[ceph.git] / ceph / src / test / librbd / test_mock_ExclusiveLock.cc
index 2a3388bdb39a04bc94b63113161a7de78cbd56d8..2d5d0c62ba327b94b15f298a76a1172b625d7a3c 100644 (file)
@@ -214,24 +214,25 @@ public:
       .WillOnce(Return(ret_val));
   }
 
-  void expect_set_require_lock_on_read(MockExclusiveLockImageCtx &mock_image_ctx) {
-    EXPECT_CALL(*mock_image_ctx.io_work_queue, set_require_lock_on_read());
-  }
-
-  void expect_clear_require_lock_on_read(MockExclusiveLockImageCtx &mock_image_ctx) {
-    EXPECT_CALL(*mock_image_ctx.io_work_queue, clear_require_lock_on_read());
+  void expect_set_require_lock(MockExclusiveLockImageCtx &mock_image_ctx,
+                               io::Direction direction, bool enabled) {
+    EXPECT_CALL(*mock_image_ctx.io_work_queue, set_require_lock(direction,
+                                                                enabled));
   }
 
   void expect_block_writes(MockExclusiveLockImageCtx &mock_image_ctx) {
     EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
                   .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
-    if ((mock_image_ctx.features & RBD_FEATURE_JOURNALING) != 0) {
-      expect_set_require_lock_on_read(mock_image_ctx);
+    if (mock_image_ctx.clone_copy_on_read ||
+        (mock_image_ctx.features & RBD_FEATURE_JOURNALING) != 0) {
+      expect_set_require_lock(mock_image_ctx, io::DIRECTION_BOTH, true);
+    } else {
+      expect_set_require_lock(mock_image_ctx, io::DIRECTION_WRITE, true);
     }
   }
 
   void expect_unblock_writes(MockExclusiveLockImageCtx &mock_image_ctx) {
-    expect_clear_require_lock_on_read(mock_image_ctx);
+    expect_set_require_lock(mock_image_ctx, io::DIRECTION_BOTH, false);
     EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes());
   }
 
@@ -272,11 +273,6 @@ public:
       .Times(1);
   }
 
-  void expect_is_lock_request_needed(MockExclusiveLockImageCtx &mock_image_ctx, bool ret) {
-    EXPECT_CALL(*mock_image_ctx.io_work_queue, is_lock_request_needed())
-                  .WillRepeatedly(Return(ret));
-  }
-
   void expect_flush_notifies(MockExclusiveLockImageCtx &mock_image_ctx) {
     EXPECT_CALL(*mock_image_ctx.image_watcher, flush(_))
                   .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
@@ -382,7 +378,6 @@ TEST_F(TestMockExclusiveLock, StateTransitions) {
   expect_is_state_pre_releasing(exclusive_lock, false);
   expect_is_state_releasing(exclusive_lock, true);
   expect_notify_released_lock(mock_image_ctx);
-  expect_is_lock_request_needed(mock_image_ctx, false);
   ASSERT_EQ(0, when_post_release_lock_handler(exclusive_lock, false, 0));
 
   // (try) acquire lock