]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: use 'open snap by id' in refresh parent request
authorMykola Golub <mgolub@suse.com>
Fri, 25 May 2018 13:35:02 +0000 (16:35 +0300)
committerJason Dillaman <dillaman@redhat.com>
Tue, 14 Aug 2018 22:29:45 +0000 (18:29 -0400)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/image/RefreshParentRequest.cc
src/librbd/image/RefreshParentRequest.h

index 5bb00a66834708325d37d006985292640a517c72..5c55f2fa720ef27a7277a515870e45773e5b275c 100644 (file)
@@ -10,7 +10,6 @@
 #include "librbd/Utils.h"
 #include "librbd/image/CloseRequest.h"
 #include "librbd/image/OpenRequest.h"
-#include "librbd/image/SetSnapRequest.h"
 #include "librbd/io/ObjectDispatcher.h"
 
 #define dout_subsys ceph_subsys_rbd
@@ -127,8 +126,8 @@ void RefreshParentRequest<I>::send_open_parent() {
     flags |= OPEN_FLAG_OLD_FORMAT;
   }
 
-  m_parent_image_ctx = new I(image_name, m_parent_md.spec.image_id, nullptr,
-                             parent_io_ctx, true);
+  m_parent_image_ctx = new I(image_name, m_parent_md.spec.image_id,
+                             m_parent_md.spec.snap_id, parent_io_ctx, true);
   m_parent_image_ctx->child = &m_child_image_ctx;
 
   // set rados flags for reading the parent image
@@ -159,44 +158,6 @@ Context *RefreshParentRequest<I>::handle_open_parent(int *result) {
     // image already closed by open state machine
     delete m_parent_image_ctx;
     m_parent_image_ctx = nullptr;
-
-    return m_on_finish;
-  }
-
-  if (m_parent_md.spec.snap_id == CEPH_NOSNAP) {
-    return m_on_finish;
-  }
-
-  send_set_parent_snap();
-  return nullptr;
-}
-
-template <typename I>
-void RefreshParentRequest<I>::send_set_parent_snap() {
-  assert(m_parent_md.spec.snap_id != CEPH_NOSNAP);
-
-  CephContext *cct = m_child_image_ctx.cct;
-  ldout(cct, 10) << this << " " << __func__ << dendl;
-
-  using klass = RefreshParentRequest<I>;
-  Context *ctx = create_context_callback<
-    klass, &klass::handle_set_parent_snap, false>(this);
-  SetSnapRequest<I> *req = SetSnapRequest<I>::create(
-    *m_parent_image_ctx, m_parent_md.spec.snap_id, ctx);
-  req->send();
-}
-
-template <typename I>
-Context *RefreshParentRequest<I>::handle_set_parent_snap(int *result) {
-  CephContext *cct = m_child_image_ctx.cct;
-  ldout(cct, 10) << this << " " << __func__ << " r=" << *result << dendl;
-
-  save_result(result);
-  if (*result < 0) {
-    lderr(cct) << "failed to set parent snapshot: " << cpp_strerror(*result)
-               << dendl;
-    send_close_parent();
-    return nullptr;
   }
 
   return m_on_finish;
index aeedbf88c69f0207730524c6e94da1eed950d533..39abc1b789c7d239e9b1b8051f94f85694a2b420 100644 (file)
@@ -43,13 +43,10 @@ private:
    *    | (open required)
    *    |----------------> OPEN_PARENT * * * * * * * * * * * * * * *
    *    |                     |                                    *
-   *    |                     v                                    *
-   *    |                  SET_PARENT_SNAP * * * * * *             *
-   *    |                     |                      *             *
-   *    |                     v                      * (on error)  *
-   *    \----------------> <apply>                   *             *
-   *                          |                      *             *
-   *                          | (close required)     v             *
+   *    |                     v                        (on error)  *
+   *    \----------------> <apply>                                 *
+   *                          |                                    *
+   *                          | (close required)                   *
    *                          |-----------------> CLOSE_PARENT     *
    *                          |                      |             *
    *                          |                      v             *
@@ -87,9 +84,6 @@ private:
   void send_open_parent();
   Context *handle_open_parent(int *result);
 
-  void send_set_parent_snap();
-  Context *handle_set_parent_snap(int *result);
-
   void send_close_parent();
   Context *handle_close_parent(int *result);