From b2b0aca970beac09e00bd84d90b5694be4ed4a62 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sat, 30 May 2020 09:44:17 +0100 Subject: [PATCH] librbd: send unquiesce even if quiesce failed If several clients are subscribed it may fail for only some of them, thus tell the succeeded clients to unquiesce so they do not wait for timeout. Signed-off-by: Mykola Golub --- src/librbd/operation/SnapshotCreateRequest.cc | 10 ++++++++-- src/librbd/operation/SnapshotCreateRequest.h | 13 +++++++------ .../operation/test_mock_SnapshotCreateRequest.cc | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc index 5966095caea..15d8e2f7a28 100644 --- a/src/librbd/operation/SnapshotCreateRequest.cc +++ b/src/librbd/operation/SnapshotCreateRequest.cc @@ -79,7 +79,9 @@ Context *SnapshotCreateRequest::handle_notify_quiesce(int *result) { if (*result < 0) { lderr(cct) << "failed to notify quiesce: " << cpp_strerror(*result) << dendl; - return this->create_context_finisher(*result); + save_result(result); + send_notify_unquiesce(); + return nullptr; } std::shared_lock owner_locker{image_ctx.owner_lock}; @@ -133,6 +135,8 @@ Context *SnapshotCreateRequest::handle_suspend_aio(int *result) { return send_notify_unquiesce(); } + m_writes_blocked = true; + send_append_op_event(); return nullptr; } @@ -357,7 +361,9 @@ Context *SnapshotCreateRequest::send_notify_unquiesce() { CephContext *cct = image_ctx.cct; ldout(cct, 5) << this << " " << __func__ << dendl; - image_ctx.io_image_dispatcher->unblock_writes(); + if (m_writes_blocked) { + image_ctx.io_image_dispatcher->unblock_writes(); + } if (m_skip_notify_quiesce) { return this->create_context_finisher(m_ret_val); diff --git a/src/librbd/operation/SnapshotCreateRequest.h b/src/librbd/operation/SnapshotCreateRequest.h index db653817e7f..20e591e71be 100644 --- a/src/librbd/operation/SnapshotCreateRequest.h +++ b/src/librbd/operation/SnapshotCreateRequest.h @@ -29,12 +29,12 @@ public: * * | * v - * STATE_NOTIFY_QUIESCE - * | - * v - * STATE_SUSPEND_REQUESTS - * | - * v + * STATE_NOTIFY_QUIESCE * * * * * * * * * * * * * + * | * + * v * + * STATE_SUSPEND_REQUESTS * + * | * + * v * * STATE_SUSPEND_AIO * * * * * * * * * * * * * * * * | * * v * @@ -94,6 +94,7 @@ private: uint64_t m_request_id = 0; int m_ret_val = 0; + bool m_writes_blocked = false; uint64_t m_snap_id = CEPH_NOSNAP; uint64_t m_size; diff --git a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc index f43b39f3601..e2032a08405 100644 --- a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc +++ b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc @@ -206,6 +206,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, NotifyQuiesceError) { ::testing::InSequence seq; expect_notify_quiesce(mock_image_ctx, -EINVAL); + expect_notify_unquiesce(mock_image_ctx, 0); C_SaferCond cond_ctx; librbd::NoOpProgressContext prog_ctx; -- 2.47.3