From 43f439109fe6902094b1663995b424aa12902ddd Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 17 Apr 2023 23:31:37 +0200 Subject: [PATCH] librbd: always refresh after creating snapshot in CreatePrimaryRequest Up until now this was conditioned on whether the caller expressed interest in the ID of the created snapshot and happened to work only because CreatePrimaryRequest wasn't actually consulting any mirror snapshot metadata. This has just changed with unlink_peer() needing to see an up-to-date complete flag which is set in SetImageStateRequest following the write out of image state object(s). Signed-off-by: Ilya Dryomov Signed-off-by: Prasanna Kumar Kalever --- src/librbd/mirror/snapshot/CreatePrimaryRequest.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc b/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc index 5a6115cd4f4ec..ae8c045e16ba3 100644 --- a/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc +++ b/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc @@ -143,13 +143,8 @@ void CreatePrimaryRequest::handle_create_snapshot(int r) { template void CreatePrimaryRequest::refresh_image() { - // if snapshot created via remote RPC, refresh is required to retrieve - // the snapshot id - if (m_snap_id == nullptr) { - unlink_peer(); - return; - } - + // refresh is required to retrieve the snapshot id (if snapshot + // created via remote RPC) and complete flag (regardless) CephContext *cct = m_image_ctx->cct; ldout(cct, 15) << dendl; @@ -170,7 +165,7 @@ void CreatePrimaryRequest::handle_refresh_image(int r) { return; } - { + if (m_snap_id != nullptr) { std::shared_lock image_locker{m_image_ctx->image_lock}; *m_snap_id = m_image_ctx->get_snap_id( cls::rbd::MirrorSnapshotNamespace{}, m_snap_name); -- 2.39.5