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
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H
#define CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H
#include "include/buffer_fwd.h"
#include "include/rados/librados_fwd.hpp"
#include "include/rbd/librbd.hpp"
#include "cls/rbd/cls_rbd_types.h"
#include "librbd/ImageCtx.h"
#include "librbd/mirror/Types.h"
#include <map>
#include <string>
class Context;
namespace librbd {
namespace asio { struct ContextWQ; }
namespace mirror {
template <typename ImageCtxT = ImageCtx>
class EnableRequest {
public:
static EnableRequest *create(ImageCtxT *image_ctx,
cls::rbd::MirrorImageMode mode,
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,
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,
bool image_clean, asio::ContextWQ *op_work_queue,
Context *on_finish) {
return new EnableRequest(io_ctx, image_id, nullptr, mode,
non_primary_global_image_id, image_clean,
op_work_queue, on_finish);
}
void send();
private:
/**
* @verbatim
*
* <start>
* |
* v
* GET_MIRROR_IMAGE * * * * * * *
* | * (on error)
* v (skip if not needed) *
* 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 *
* | *
* v (skip if not needed) *
* IMAGE_STATE_UPDATE * * * * * *
* | *
* v *
* <finish> < * * * * * * * * *
*
* @endverbatim
*/
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,
bool image_clean, asio::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;
asio::ContextWQ *m_op_work_queue;
Context *m_on_finish;
CephContext *m_cct = nullptr;
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;
void get_mirror_image();
void handle_get_mirror_image(int r);
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);
void image_state_update();
void handle_image_state_update(int r);
void finish(int r);
};
} // namespace mirror
} // namespace librbd
extern template class librbd::mirror::EnableRequest<librbd::ImageCtx>;
#endif // CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H
|