From: Mykola Golub Date: Mon, 22 Feb 2021 12:54:43 +0000 (+0000) Subject: librbd: use on-disk image name when storing mirror snapshot state X-Git-Tag: v16.2.0~181^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f90d95cbdc2dc7c21dbae20b3ada001e7eb32dcc;p=ceph.git librbd: use on-disk image name when storing mirror snapshot state Fixes: https://tracker.ceph.com/issues/49115 Signed-off-by: Mykola Golub (cherry picked from commit 813728ae2036231a269be86bcb3dc48951a20f21) --- diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.cc b/src/librbd/mirror/snapshot/SetImageStateRequest.cc index f68bff8b92c..9fcee032291 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.cc +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.cc @@ -27,6 +27,45 @@ using librbd::util::create_rados_callback; template void SetImageStateRequest::send() { + get_name(); +} + +template +void SetImageStateRequest::get_name() { + CephContext *cct = m_image_ctx->cct; + ldout(cct, 15) << dendl; + + librados::ObjectReadOperation op; + cls_client::dir_get_name_start(&op, m_image_ctx->id); + + librados::AioCompletion *comp = create_rados_callback< + SetImageStateRequest, + &SetImageStateRequest::handle_get_name>(this); + m_bl.clear(); + int r = m_image_ctx->md_ctx.aio_operate(RBD_DIRECTORY, comp, &op, &m_bl); + ceph_assert(r == 0); + comp->release(); +} + +template +void SetImageStateRequest::handle_get_name(int r) { + CephContext *cct = m_image_ctx->cct; + ldout(cct, 15) << "r=" << r << dendl; + + if (r == 0) { + auto it = m_bl.cbegin(); + r = cls_client::dir_get_name_finish(&it, &m_image_state.name); + } + + if (r < 0) { + lderr(cct) << "failed to retrieve image name: " << cpp_strerror(r) + << dendl; + finish(r); + return; + } + + ldout(cct, 15) << "name=" << m_image_state.name << dendl; + get_snap_limit(); } @@ -99,7 +138,6 @@ void SetImageStateRequest::handle_get_metadata(int r) { { std::shared_lock image_locker{m_image_ctx->image_lock}; - m_image_state.name = m_image_ctx->name; m_image_state.features = m_image_ctx->features & ~RBD_FEATURES_IMPLICIT_ENABLE; diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.h b/src/librbd/mirror/snapshot/SetImageStateRequest.h index df903a279ab..fd281549489 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.h +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.h @@ -40,6 +40,9 @@ private: * * | * v + * GET_NAME + * | + * v * GET_SNAP_LIMIT * | * v @@ -66,6 +69,9 @@ private: bufferlist m_bl; bufferlist m_state_bl; + void get_name(); + void handle_get_name(int r); + void get_snap_limit(); void handle_get_snap_limit(int r);