]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_replayer/OpenImageRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / OpenImageRequest.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_REPLAYER_OPEN_IMAGE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_OPEN_IMAGE_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "librbd/ImageCtx.h"
9 #include <string>
10
11 class Context;
12 namespace librbd { class ImageCtx; }
13
14 namespace rbd {
15 namespace mirror {
16 namespace image_replayer {
17
18 template <typename ImageCtxT = librbd::ImageCtx>
19 class OpenImageRequest {
20 public:
21 static OpenImageRequest* create(librados::IoCtx &io_ctx,
22 ImageCtxT **image_ctx,
23 const std::string &image_id,
24 bool read_only, Context *on_finish) {
25 return new OpenImageRequest(io_ctx, image_ctx, image_id, read_only,
26 on_finish);
27 }
28
29 OpenImageRequest(librados::IoCtx &io_ctx, ImageCtxT **image_ctx,
30 const std::string &image_id, bool read_only,
31 Context *on_finish);
32
33 void send();
34
35 private:
36 /**
37 * @verbatim
38 *
39 * <start>
40 * |
41 * v
42 * OPEN_IMAGE
43 * |
44 * v
45 * <finish>
46 *
47 * @endverbatim
48 */
49 librados::IoCtx &m_io_ctx;
50 ImageCtxT **m_image_ctx;
51 std::string m_image_id;
52 bool m_read_only;
53 Context *m_on_finish;
54
55 void send_open_image();
56 void handle_open_image(int r);
57
58 void send_close_image(int r);
59 void handle_close_image(int r);
60
61 void finish(int r);
62
63 };
64
65 } // namespace image_replayer
66 } // namespace mirror
67 } // namespace rbd
68
69 extern template class rbd::mirror::image_replayer::OpenImageRequest<librbd::ImageCtx>;
70
71 #endif // RBD_MIRROR_IMAGE_REPLAYER_OPEN_IMAGE_REQUEST_H