]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: snapshot image-state should use get image-meta state machine
authorJason Dillaman <dillaman@redhat.com>
Tue, 25 Feb 2020 14:00:44 +0000 (09:00 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 27 Feb 2020 13:22:58 +0000 (08:22 -0500)
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 <dillaman@redhat.com>
src/librbd/mirror/snapshot/SetImageStateRequest.cc
src/librbd/mirror/snapshot/SetImageStateRequest.h

index fae3bcb599111cab6c709b73f67679e0d39d0741..cc2ff16f68dc687b75d3fb582e7bc02420f04a24 100644 (file)
@@ -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 <boost/algorithm/string/predicate.hpp>
@@ -78,19 +79,15 @@ void SetImageStateRequest<I>::handle_get_snap_limit(int r) {
 template <typename I>
 void SetImageStateRequest<I>::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<I>,
-    &SetImageStateRequest<I>::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<I>,
+     &SetImageStateRequest<I>::handle_get_metadata>(this);
+  auto req = image::GetMetadataRequest<I>::create(
+    m_image_ctx->md_ctx, m_image_ctx->header_oid, true, "", "", 0,
+    &m_image_state.metadata, ctx);
+  req->send();
 }
 
 template <typename I>
@@ -98,12 +95,6 @@ void SetImageStateRequest<I>::handle_get_metadata(int r) {
   CephContext *cct = m_image_ctx->cct;
   ldout(cct, 20) << "r=" << r << dendl;
 
-  std::map<std::string, bufferlist> 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<I>::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};
 
index 663c281340452eb40a72357851c424f9ed21bb6f..df903a279ab878798df30fd40f32e6622d97fe4e 100644 (file)
@@ -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);