]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/mirror/DemoteRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / librbd / mirror / DemoteRequest.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_LIBRBD_MIRROR_DEMOTE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_DEMOTE_REQUEST_H
6
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "librbd/mirror/Types.h"
9
10 struct Context;
11
12 namespace librbd {
13
14 struct ImageCtx;
15
16 namespace mirror {
17
18 template <typename ImageCtxT = librbd::ImageCtx>
19 class DemoteRequest {
20 public:
21 static DemoteRequest *create(ImageCtxT &image_ctx, Context *on_finish) {
22 return new DemoteRequest(image_ctx, on_finish);
23 }
24
25 DemoteRequest(ImageCtxT &image_ctx, Context *on_finish)
26 : m_image_ctx(image_ctx), m_on_finish(on_finish) {
27 }
28
29 void send();
30
31 private:
32 /**
33 * @verbatim
34 *
35 * <start>
36 * |
37 * v
38 * GET_INFO
39 * |
40 * v
41 * ACQUIRE_LOCK * * * *
42 * | *
43 * v *
44 * DEMOTE *
45 * | *
46 * v *
47 * RELEASE_LOCK *
48 * | *
49 * v *
50 * <finish> < * * * * *
51 *
52 * @endverbatim
53 */
54
55 ImageCtxT &m_image_ctx;
56 Context *m_on_finish;
57
58 int m_ret_val = 0;
59 bool m_blocked_requests = false;
60
61 cls::rbd::MirrorImage m_mirror_image;
62 PromotionState m_promotion_state;
63
64 void get_info();
65 void handle_get_info(int r);
66
67 void acquire_lock();
68 void handle_acquire_lock(int r);
69
70 void demote();
71 void handle_demote(int r);
72
73 void release_lock();
74 void handle_release_lock(int r);
75
76 void finish(int r);
77
78 };
79
80 } // namespace mirror
81 } // namespace librbd
82
83 extern template class librbd::mirror::DemoteRequest<librbd::ImageCtx>;
84
85 #endif // CEPH_LIBRBD_MIRROR_DEMOTE_REQUEST_H