]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/deep_copy/ImageCopyRequest.h
bump version to 15.2.1-pve1
[ceph.git] / ceph / src / librbd / deep_copy / ImageCopyRequest.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_LIBRBD_DEEP_COPY_IMAGE_DEEP_COPY_REQUEST_H
5#define CEPH_LIBRBD_DEEP_COPY_IMAGE_DEEP_COPY_REQUEST_H
6
7#include "include/int_types.h"
8#include "include/rados/librados.hpp"
9f95a23c
TL
9#include "common/bit_vector.hpp"
10#include "common/ceph_mutex.h"
11fdf7f2
TL
11#include "common/RefCountedObj.h"
12#include "librbd/Types.h"
13#include "librbd/deep_copy/Types.h"
14#include <functional>
15#include <map>
16#include <queue>
17#include <vector>
18#include <boost/optional.hpp>
19
20class Context;
21
22namespace librbd {
23
24class ImageCtx;
25class ProgressContext;
26
27namespace deep_copy {
28
29template <typename ImageCtxT = ImageCtx>
30class ImageCopyRequest : public RefCountedObject {
31public:
32 static ImageCopyRequest* create(ImageCtxT *src_image_ctx,
33 ImageCtxT *dst_image_ctx,
9f95a23c
TL
34 librados::snap_t src_snap_id_start,
35 librados::snap_t src_snap_id_end,
36 librados::snap_t dst_snap_id_start,
37 bool flatten,
11fdf7f2
TL
38 const ObjectNumber &object_number,
39 const SnapSeqs &snap_seqs,
40 ProgressContext *prog_ctx,
41 Context *on_finish) {
9f95a23c
TL
42 return new ImageCopyRequest(src_image_ctx, dst_image_ctx, src_snap_id_start,
43 src_snap_id_end, dst_snap_id_start, flatten,
44 object_number, snap_seqs, prog_ctx, on_finish);
11fdf7f2
TL
45 }
46
47 ImageCopyRequest(ImageCtxT *src_image_ctx, ImageCtxT *dst_image_ctx,
9f95a23c
TL
48 librados::snap_t src_snap_id_start,
49 librados::snap_t src_snap_id_end,
50 librados::snap_t dst_snap_id_start,
11fdf7f2
TL
51 bool flatten, const ObjectNumber &object_number,
52 const SnapSeqs &snap_seqs, ProgressContext *prog_ctx,
53 Context *on_finish);
54
55 void send();
56 void cancel();
57
58private:
59 /**
60 * @verbatim
61 *
62 * <start>
9f95a23c
TL
63 * |
64 * v
65 * COMPUTE_DIFF
66 * |
11fdf7f2
TL
67 * | . . . . .
68 * | . . (parallel execution of
69 * v v . multiple objects at once)
70 * COPY_OBJECT . . . .
71 * |
72 * v
73 * <finish>
74 *
75 * @endverbatim
76 */
77
78 ImageCtxT *m_src_image_ctx;
79 ImageCtxT *m_dst_image_ctx;
9f95a23c
TL
80 librados::snap_t m_src_snap_id_start;
81 librados::snap_t m_src_snap_id_end;
82 librados::snap_t m_dst_snap_id_start;
11fdf7f2
TL
83 bool m_flatten;
84 ObjectNumber m_object_number;
85 SnapSeqs m_snap_seqs;
86 ProgressContext *m_prog_ctx;
87 Context *m_on_finish;
88
89 CephContext *m_cct;
9f95a23c 90 ceph::mutex m_lock;
11fdf7f2
TL
91 bool m_canceled = false;
92
93 uint64_t m_object_no = 0;
94 uint64_t m_end_object_no = 0;
95 uint64_t m_current_ops = 0;
96 std::priority_queue<
97 uint64_t, std::vector<uint64_t>, std::greater<uint64_t>> m_copied_objects;
98 bool m_updating_progress = false;
99 SnapMap m_snap_map;
100 int m_ret_val = 0;
101
9f95a23c
TL
102 BitVector<2> m_object_diff_state;
103
104 void compute_diff();
105 void handle_compute_diff(int r);
106
11fdf7f2 107 void send_object_copies();
9f95a23c 108 int send_next_object_copy();
11fdf7f2
TL
109 void handle_object_copy(uint64_t object_no, int r);
110
111 void finish(int r);
112};
113
114} // namespace deep_copy
115} // namespace librbd
116
117extern template class librbd::deep_copy::ImageCopyRequest<librbd::ImageCtx>;
118
119#endif // CEPH_LIBRBD_DEEP_COPY_IMAGE_DEEP_COPY_REQUEST_H