.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());
}
.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));
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