]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_sync/MetadataCopyRequest.h
update sources to v12.2.3
[ceph.git] / ceph / src / tools / rbd_mirror / image_sync / MetadataCopyRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef RBD_MIRROR_IMAGE_SYNC_METADATA_COPY_REQUEST_H
5 #define RBD_MIRROR_IMAGE_SYNC_METADATA_COPY_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "include/buffer.h"
9 #include "include/rados/librados.hpp"
10 #include "librbd/ImageCtx.h"
11 #include <map>
12 #include <string>
13
14 class Context;
15
16 namespace rbd {
17 namespace mirror {
18 namespace image_sync {
19
20 template <typename ImageCtxT = librbd::ImageCtx>
21 class MetadataCopyRequest {
22 public:
23 static MetadataCopyRequest* create(ImageCtxT *local_image_ctx,
24 ImageCtxT *remote_image_ctx,
25 Context *on_finish) {
26 return new MetadataCopyRequest(local_image_ctx, remote_image_ctx,
27 on_finish);
28 }
29
30 MetadataCopyRequest(ImageCtxT *local_image_ctx, ImageCtxT *remote_image_ctx,
31 Context *on_finish)
32 : m_local_image_ctx(local_image_ctx), m_remote_image_ctx(remote_image_ctx),
33 m_on_finish(on_finish) {
34 }
35
36 void send();
37
38 private:
39 /**
40 * @verbatim
41 *
42 * <start>
43 * |
44 * v
45 * LIST_REMOTE_METADATA <-----\
46 * | | (repeat if additional
47 * v | metadata)
48 * SET_LOCAL_METADATA --------/
49 * |
50 * v
51 * <finish>
52 *
53 * @endverbatim
54 */
55 typedef std::map<std::string, bufferlist> Metadata;
56
57 ImageCtxT *m_local_image_ctx;
58 ImageCtxT *m_remote_image_ctx;
59 Context *m_on_finish;
60
61 bufferlist m_out_bl;
62
63 std::string m_last_metadata_key;
64 bool m_more_metadata = false;
65
66 void list_remote_metadata();
67 void handle_list_remote_data(int r);
68
69 void set_local_metadata(const Metadata& metadata);
70 void handle_set_local_metadata(int r);
71
72 void finish(int r);
73
74 };
75
76 } // namespace image_sync
77 } // namespace mirror
78 } // namespace rbd
79
80 extern template class rbd::mirror::image_sync::MetadataCopyRequest<librbd::ImageCtx>;
81
82 #endif // RBD_MIRROR_IMAGE_SYNC_METADATA_COPY_REQUEST_H