1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
#define CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
#include "cls/rbd/cls_rbd_types.h"
#include "common/config_fwd.h"
#include "librbd/internal.h"
#include "include/rbd/librbd.hpp"
class Context;
using librados::IoCtx;
namespace librbd {
namespace asio { struct ContextWQ; }
namespace image {
template <typename ImageCtxT = ImageCtx>
class CloneRequest {
public:
static CloneRequest *create(
ConfigProxy& config, IoCtx& parent_io_ctx,
const std::string& parent_image_id,
const std::string& parent_snap_name,
const cls::rbd::SnapshotNamespace& parent_snap_namespace,
uint64_t parent_snap_id,
IoCtx &c_ioctx, const std::string &c_name,
const std::string &c_id, ImageOptions c_options,
cls::rbd::MirrorImageMode mirror_image_mode,
const std::string &non_primary_global_image_id,
const std::string &primary_mirror_uuid,
asio::ContextWQ *op_work_queue, Context *on_finish) {
return new CloneRequest(config, parent_io_ctx, parent_image_id,
parent_snap_name, parent_snap_namespace,
parent_snap_id, c_ioctx, c_name, c_id, c_options,
mirror_image_mode, non_primary_global_image_id,
primary_mirror_uuid, op_work_queue, on_finish);
}
CloneRequest(ConfigProxy& config, IoCtx& parent_io_ctx,
const std::string& parent_image_id,
const std::string& parent_snap_name,
const cls::rbd::SnapshotNamespace& parent_snap_namespace,
uint64_t parent_snap_id,
IoCtx &c_ioctx, const std::string &c_name,
const std::string &c_id, ImageOptions c_options,
cls::rbd::MirrorImageMode mirror_image_mode,
const std::string &non_primary_global_image_id,
const std::string &primary_mirror_uuid,
asio::ContextWQ *op_work_queue, Context *on_finish);
void send();
private:
/**
* @verbatim
*
* <start>
* |
* v
* OPEN PARENT
* |
* v
* VALIDATE CHILD <finish>
* | ^
* v |
* CREATE CHILD * * * * * * * * * > CLOSE PARENT
* | ^
* v |
* OPEN CHILD * * * * * * * * * * > REMOVE CHILD
* | ^
* v |
* ATTACH PARENT * * * * * * * * > CLOSE CHILD
* | ^
* v *
* ATTACH CHILD * * * * * * * * * * * *
* | *
* v *
* COPY META DATA * * * * * * * * * * ^
* | *
* v (skip if not needed) *
* GET MIRROR MODE * * * * * * * * * ^
* | *
* v (skip if not needed) *
* SET MIRROR ENABLED * * * * * * * * *
* |
* v
* CLOSE CHILD
* |
* v
* CLOSE PARENT
* |
* v
* <finish>
*
* @endverbatim
*/
ConfigProxy& m_config;
IoCtx &m_parent_io_ctx;
std::string m_parent_image_id;
std::string m_parent_snap_name;
cls::rbd::SnapshotNamespace m_parent_snap_namespace;
uint64_t m_parent_snap_id;
ImageCtxT *m_parent_image_ctx;
IoCtx &m_ioctx;
std::string m_name;
std::string m_id;
ImageOptions m_opts;
cls::rbd::ParentImageSpec m_pspec;
ImageCtxT *m_imctx;
cls::rbd::MirrorMode m_mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
cls::rbd::MirrorImageMode m_mirror_image_mode;
const std::string m_non_primary_global_image_id;
const std::string m_primary_mirror_uuid;
NoOpProgressContext m_no_op;
asio::ContextWQ *m_op_work_queue;
Context *m_on_finish;
CephContext *m_cct;
uint64_t m_clone_format = 2;
bool m_use_p_features;
uint64_t m_features;
bufferlist m_out_bl;
uint64_t m_size;
int m_r_saved = 0;
void validate_options();
void open_parent();
void handle_open_parent(int r);
void validate_parent();
void validate_child();
void handle_validate_child(int r);
void create_child();
void handle_create_child(int r);
void open_child();
void handle_open_child(int r);
void attach_parent();
void handle_attach_parent(int r);
void attach_child();
void handle_attach_child(int r);
void copy_metadata();
void handle_copy_metadata(int r);
void get_mirror_mode();
void handle_get_mirror_mode(int r);
void enable_mirror();
void handle_enable_mirror(int r);
void close_child();
void handle_close_child(int r);
void remove_child();
void handle_remove_child(int r);
void close_parent();
void handle_close_parent(int r);
void complete(int r);
};
} //namespace image
} //namespace librbd
extern template class librbd::image::CloneRequest<librbd::ImageCtx>;
#endif // CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
|