1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "include/rbd/librbd.hpp"
9 #include "librbd/internal.h"
13 using librados::IoCtx;
18 template <typename ImageCtxT = ImageCtx>
21 static CloneRequest *create(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
22 const std::string &c_id, ImageOptions c_options,
23 const std::string &non_primary_global_image_id,
24 const std::string &primary_mirror_uuid,
25 ContextWQ *op_work_queue, Context *on_finish) {
26 return new CloneRequest(p_imctx, c_ioctx, c_name, c_id, c_options,
27 non_primary_global_image_id, primary_mirror_uuid,
28 op_work_queue, on_finish);
42 * (error: bottom up) VALIDATE CHILD
47 * | | v (parent_md exists)
48 * | | OPEN IMAGE. . . . . > . . . .
50 * | REMOVE IMAGE<--------/ v .
51 * | | SET PARENT IN HEADER .
53 * | ^-------<------/ v .
54 * | |\ UPDATE DIR_CHILDREN. . < . . .
56 * | | *<-----------/ v
59 * | CLEAN DIR_CHILDREN <--------/ v (meta is empty)
60 * | |\ GET META IN PARENT . . . . . . .
62 * v | *<-----------/ v (journaling disabled) .
63 * | | SET META IN CHILD . . . . . . . v
65 * | -------<-------/ v (no need to enable mirror) .
66 * | | GET MIRROR MODE . . . . . . . v
68 * | -------<-------/ v .
69 * | | ENABLE MIRROR MODE v
71 * | -------<-------/ v .
72 * | CLOSE IMAGE . . . . .< . . .
75 * |_____________>__________________<finish>
80 CloneRequest(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
81 const std::string &c_id,
82 ImageOptions c_options,
83 const std::string &non_primary_global_image_id,
84 const std::string &primary_mirror_uuid,
85 ContextWQ *op_work_queue, Context *on_finish);
94 cls::rbd::MirrorMode m_mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
95 const std::string m_non_primary_global_image_id;
96 const std::string m_primary_mirror_uuid;
97 NoOpProgressContext m_no_op;
98 ContextWQ *m_op_work_queue;
102 bool m_use_p_features;
103 uint64_t m_p_features;
105 map<string, bufferlist> m_pairs;
110 bool m_force_non_primary;
112 void validate_options();
114 void send_validate_parent();
115 void handle_validate_parent(int r);
117 void send_validate_child();
118 void handle_validate_child(int r);
121 void handle_create(int r);
124 void handle_open(int r);
126 void send_set_parent();
127 void handle_set_parent(int r);
129 void send_add_child();
130 void handle_add_child(int r);
133 void handle_refresh(int r);
135 void send_metadata_list();
136 void handle_metadata_list(int r);
138 void send_metadata_set();
139 void handle_metadata_set(int r);
141 void get_mirror_mode();
142 void handle_get_mirror_mode(int r);
144 void send_enable_mirror();
145 void handle_enable_mirror(int r);
148 void handle_close(int r);
151 void handle_remove(int r);
153 void send_remove_child();
154 void handle_remove_child(int r);
156 void complete(int r);
162 extern template class librbd::image::CloneRequest<librbd::ImageCtx>;
164 #endif // CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H