]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_map/LoadRequest.h
import ceph 16.2.7
[ceph.git] / ceph / src / tools / rbd_mirror / image_map / LoadRequest.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 CEPH_RBD_MIRROR_IMAGE_MAP_LOAD_REQUEST_H
5 #define CEPH_RBD_MIRROR_IMAGE_MAP_LOAD_REQUEST_H
6
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "include/rados/librados.hpp"
9
10 class Context;
11
12 namespace librbd { class ImageCtx; }
13
14 namespace rbd {
15 namespace mirror {
16 namespace image_map {
17
18 template<typename ImageCtxT = librbd::ImageCtx>
19 class LoadRequest {
20 public:
21 static LoadRequest *create(librados::IoCtx &ioctx,
22 std::map<std::string, cls::rbd::MirrorImageMap> *image_mapping,
23 Context *on_finish) {
24 return new LoadRequest(ioctx, image_mapping, on_finish);
25 }
26
27 void send();
28
29 private:
30 /**
31 * @verbatim
32 *
33 * <start>
34 * | . . . . . . . .
35 * v v . MAX_RETURN
36 * IMAGE_MAP_LIST. . . . . . .
37 * |
38 * v
39 * MIRROR_IMAGE_LIST
40 * |
41 * v
42 * CLEANUP_IMAGE_MAP
43 * |
44 * v
45 * <finish>
46 *
47 * @endverbatim
48 */
49 LoadRequest(librados::IoCtx &ioctx,
50 std::map<std::string, cls::rbd::MirrorImageMap> *image_mapping,
51 Context *on_finish);
52
53 librados::IoCtx &m_ioctx;
54 std::map<std::string, cls::rbd::MirrorImageMap> *m_image_mapping;
55 Context *m_on_finish;
56
57 std::set<std::string> m_global_image_ids;
58
59 bufferlist m_out_bl;
60 std::string m_start_after;
61
62 void image_map_list();
63 void handle_image_map_list(int r);
64
65 void mirror_image_list();
66 void handle_mirror_image_list(int r);
67
68 void cleanup_image_map();
69
70 void finish(int r);
71 };
72
73 } // namespace image_map
74 } // namespace mirror
75 } // namespace rbd
76
77 #endif // CEPH_RBD_MIRROR_IMAGE_MAP_LOAD_REQUEST_H