From ae2b13fe7f64bb8046dab046cae5e4661f5966ad Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 25 Feb 2020 09:00:44 -0500 Subject: [PATCH] librbd: snapshot image-state should use get image-meta state machine This commit was accidentally dropped from commit bcbdd6cf698 when all existing logic was updated to use the new helper state machine. Signed-off-by: Jason Dillaman --- .../mirror/snapshot/SetImageStateRequest.cc | 37 +++++-------------- .../mirror/snapshot/SetImageStateRequest.h | 5 +-- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.cc b/src/librbd/mirror/snapshot/SetImageStateRequest.cc index fae3bcb599111..cc2ff16f68dc6 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.cc +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.cc @@ -7,6 +7,7 @@ #include "cls/rbd/cls_rbd_client.h" #include "librbd/ImageCtx.h" #include "librbd/Utils.h" +#include "librbd/image/GetMetadataRequest.h" #include "librbd/mirror/snapshot/WriteImageStateRequest.h" #include @@ -78,19 +79,15 @@ void SetImageStateRequest::handle_get_snap_limit(int r) { template void SetImageStateRequest::get_metadata() { CephContext *cct = m_image_ctx->cct; - ldout(cct, 20) << "start_key=" << m_last_metadata_key << dendl; - - librados::ObjectReadOperation op; - cls_client::metadata_list_start(&op, m_last_metadata_key, MAX_METADATA_ITEMS); + ldout(cct, 20) << dendl; - librados::AioCompletion *comp = create_rados_callback< - SetImageStateRequest, - &SetImageStateRequest::handle_get_metadata>(this); - m_bl.clear(); - int r = m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op, - &m_bl); - ceph_assert(r == 0); - comp->release(); + auto ctx = create_context_callback< + SetImageStateRequest, + &SetImageStateRequest::handle_get_metadata>(this); + auto req = image::GetMetadataRequest::create( + m_image_ctx->md_ctx, m_image_ctx->header_oid, true, "", "", 0, + &m_image_state.metadata, ctx); + req->send(); } template @@ -98,12 +95,6 @@ void SetImageStateRequest::handle_get_metadata(int r) { CephContext *cct = m_image_ctx->cct; ldout(cct, 20) << "r=" << r << dendl; - std::map metadata; - if (r == 0) { - auto it = m_bl.cbegin(); - r = cls_client::metadata_list_finish(&it, &metadata); - } - if (r < 0) { lderr(cct) << "failed to retrieve metadata: " << cpp_strerror(r) << dendl; @@ -111,16 +102,6 @@ void SetImageStateRequest::handle_get_metadata(int r) { return; } - if (!metadata.empty()) { - m_image_state.metadata.insert(metadata.begin(), metadata.end()); - m_last_metadata_key = metadata.rbegin()->first; - if (boost::starts_with(m_last_metadata_key, - ImageCtx::METADATA_CONF_PREFIX)) { - get_metadata(); - return; - } - } - { std::shared_lock image_locker{m_image_ctx->image_lock}; diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.h b/src/librbd/mirror/snapshot/SetImageStateRequest.h index 663c281340452..df903a279ab87 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.h +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.h @@ -43,8 +43,8 @@ private: * GET_SNAP_LIMIT * | * v - * GET_METADATA (repeat until - * | all metadata read) + * GET_METADATA + * | * v * WRITE_IMAGE_STATE * | @@ -65,7 +65,6 @@ private: bufferlist m_bl; bufferlist m_state_bl; - std::string m_last_metadata_key; void get_snap_limit(); void handle_get_snap_limit(int r); -- 2.39.5