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
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_LIBRBD_DEEP_COPY_REQUEST_H
#define CEPH_LIBRBD_DEEP_COPY_REQUEST_H
#include "common/Mutex.h"
#include "common/RefCountedObj.h"
#include "include/int_types.h"
#include "librbd/ImageCtx.h"
#include "librbd/Types.h"
#include "librbd/deep_copy/Types.h"
#include <map>
#include <vector>
class Context;
namespace librbd {
class ImageCtx;
namespace deep_copy {
template <typename> class ImageCopyRequest;
template <typename> class SnapshotCopyRequest;
}
template <typename ImageCtxT = ImageCtx>
class DeepCopyRequest : public RefCountedObject {
public:
static DeepCopyRequest* create(ImageCtxT *src_image_ctx,
ImageCtxT *dst_image_ctx,
librados::snap_t src_snap_id_start,
librados::snap_t src_snap_id_end,
librados::snap_t dst_snap_id_start,
bool flatten,
const deep_copy::ObjectNumber &object_number,
ContextWQ *work_queue,
SnapSeqs *snap_seqs,
ProgressContext *prog_ctx,
Context *on_finish) {
return new DeepCopyRequest(src_image_ctx, dst_image_ctx, src_snap_id_start,
src_snap_id_end, dst_snap_id_start, flatten,
object_number, work_queue, snap_seqs, prog_ctx,
on_finish);
}
DeepCopyRequest(ImageCtxT *src_image_ctx, ImageCtxT *dst_image_ctx,
librados::snap_t src_snap_id_start,
librados::snap_t src_snap_id_end,
librados::snap_t dst_snap_id_start,
bool flatten, const deep_copy::ObjectNumber &object_number,
ContextWQ *work_queue, SnapSeqs *snap_seqs,
ProgressContext *prog_ctx, Context *on_finish);
~DeepCopyRequest();
void send();
void cancel();
private:
/**
* @verbatim
*
* <start>
* |
* v
* COPY_SNAPSHOTS
* |
* v
* COPY_IMAGE . . . . . . . . . . . . . .
* | .
* v .
* COPY_OBJECT_MAP (skip if object .
* | map disabled) .
* v .
* REFRESH_OBJECT_MAP (skip if object . (image copy canceled)
* | map disabled) .
* v .
* COPY_METADATA .
* | .
* v .
* <finish> < . . . . . . . . . . . . . .
*
* @endverbatim
*/
typedef std::vector<librados::snap_t> SnapIds;
typedef std::map<librados::snap_t, SnapIds> SnapMap;
ImageCtxT *m_src_image_ctx;
ImageCtxT *m_dst_image_ctx;
librados::snap_t m_src_snap_id_start;
librados::snap_t m_src_snap_id_end;
librados::snap_t m_dst_snap_id_start;
bool m_flatten;
deep_copy::ObjectNumber m_object_number;
ContextWQ *m_work_queue;
SnapSeqs *m_snap_seqs;
ProgressContext *m_prog_ctx;
Context *m_on_finish;
CephContext *m_cct;
Mutex m_lock;
bool m_canceled = false;
deep_copy::SnapshotCopyRequest<ImageCtxT> *m_snapshot_copy_request = nullptr;
deep_copy::ImageCopyRequest<ImageCtxT> *m_image_copy_request = nullptr;
decltype(ImageCtxT::object_map) m_object_map = nullptr;
void send_copy_snapshots();
void handle_copy_snapshots(int r);
void send_copy_image();
void handle_copy_image(int r);
void send_copy_object_map();
void handle_copy_object_map(int r);
void send_refresh_object_map();
void handle_refresh_object_map(int r);
void send_copy_metadata();
void handle_copy_metadata(int r);
int validate_copy_points();
void finish(int r);
};
} // namespace librbd
extern template class librbd::DeepCopyRequest<librbd::ImageCtx>;
#endif // CEPH_LIBRBD_DEEP_COPY_REQUEST_H
|