]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/mirror/EnableRequest.h
import 15.2.2 octopus source
[ceph.git] / ceph / src / librbd / mirror / EnableRequest.h
index c9945d7b56c7dcd90dc1cae787df8e29d72446be..574dfe2bc03d091dd8107d375d1810385ac18c02 100644 (file)
@@ -24,18 +24,21 @@ class EnableRequest {
 public:
   static EnableRequest *create(ImageCtxT *image_ctx,
                                cls::rbd::MirrorImageMode mode,
-                               Context *on_finish) {
+                               const std::string &non_primary_global_image_id,
+                               bool image_clean, Context *on_finish) {
     return new EnableRequest(image_ctx->md_ctx, image_ctx->id, image_ctx, mode,
-                             "", image_ctx->op_work_queue, on_finish);
+                             non_primary_global_image_id, image_clean,
+                             image_ctx->op_work_queue, on_finish);
   }
   static EnableRequest *create(librados::IoCtx &io_ctx,
                                const std::string &image_id,
                                cls::rbd::MirrorImageMode mode,
                                const std::string &non_primary_global_image_id,
-                               ContextWQ *op_work_queue, Context *on_finish) {
+                               bool image_clean, ContextWQ *op_work_queue,
+                               Context *on_finish) {
     return new EnableRequest(io_ctx, image_id, nullptr, mode,
-                             non_primary_global_image_id, op_work_queue,
-                             on_finish);
+                             non_primary_global_image_id, image_clean,
+                             op_work_queue, on_finish);
   }
 
   void send();
@@ -53,8 +56,14 @@ private:
    * GET_TAG_OWNER  * * * * * * * *
    *    |                         *
    *    v (skip if not needed)    *
+   * OPEN_IMAGE                   *
+   *    |                         *
+   *    v (skip if not needed)    *
    * CREATE_PRIMARY_SNAPSHOT  * * *
    *    |                         *
+   *    v (skip of not opened)    *
+   * CLOSE_IMAGE                  *
+   *    |                         *
    *    v (skip if not needed)    *
    * ENABLE_NON_PRIMARY_FEATURE   *
    *    |                         *
@@ -70,13 +79,14 @@ private:
   EnableRequest(librados::IoCtx &io_ctx, const std::string &image_id,
                 ImageCtxT* image_ctx, cls::rbd::MirrorImageMode mode,
                 const std::string &non_primary_global_image_id,
-                ContextWQ *op_work_queue, Context *on_finish);
+                bool image_clean, ContextWQ *op_work_queue, Context *on_finish);
 
   librados::IoCtx &m_io_ctx;
   std::string m_image_id;
   ImageCtxT* m_image_ctx;
   cls::rbd::MirrorImageMode m_mode;
   std::string m_non_primary_global_image_id;
+  bool m_image_clean;
   ContextWQ *m_op_work_queue;
   Context *m_on_finish;
 
@@ -84,6 +94,9 @@ private:
   bufferlist m_out_bl;
   cls::rbd::MirrorImage m_mirror_image;
 
+  int m_ret_val = 0;
+  bool m_close_image = false;
+
   bool m_is_primary = false;
   uint64_t m_snap_id = CEPH_NOSNAP;
 
@@ -93,9 +106,15 @@ private:
   void get_tag_owner();
   void handle_get_tag_owner(int r);
 
+  void open_image();
+  void handle_open_image(int r);
+
   void create_primary_snapshot();
   void handle_create_primary_snapshot(int r);
 
+  void close_image();
+  void handle_close_image(int r);
+
   void enable_non_primary_feature();
   void handle_enable_non_primary_feature(int r);