]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/operation/DisableFeaturesRequest.h
update sources to v12.1.1
[ceph.git] / ceph / src / librbd / operation / DisableFeaturesRequest.h
CommitLineData
7c673cae
FG
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_OPERATION_DISABLE_FEATURES_REQUEST_H
5#define CEPH_LIBRBD_OPERATION_DISABLE_FEATURES_REQUEST_H
6
224ce89b 7#include "librbd/ImageCtx.h"
7c673cae
FG
8#include "librbd/operation/Request.h"
9#include "cls/rbd/cls_rbd_client.h"
10
11class Context;
12
13namespace librbd {
14
15class ImageCtx;
16
17namespace operation {
18
19template <typename ImageCtxT = ImageCtx>
20class DisableFeaturesRequest : public Request<ImageCtxT> {
21public:
22 static DisableFeaturesRequest *create(ImageCtxT &image_ctx, Context *on_finish,
23 uint64_t journal_op_tid,
24 uint64_t features, bool force) {
25 return new DisableFeaturesRequest(image_ctx, on_finish, journal_op_tid,
26 features, force);
27 }
28
29 DisableFeaturesRequest(ImageCtxT &image_ctx, Context *on_finish,
30 uint64_t journal_op_tid, uint64_t features, bool force);
31
32protected:
33 void send_op() override;
34 bool should_complete(int r) override;
35 bool can_affect_io() const override {
36 return true;
37 }
38 journal::Event create_event(uint64_t op_tid) const override {
39 return journal::UpdateFeaturesEvent(op_tid, m_features, false);
40 }
41
42private:
43 /**
44 * DisableFeatures goes through the following state machine:
45 *
46 * @verbatim
47 *
48 * <start>
49 * |
50 * v
51 * STATE_PREPARE_LOCK
52 * |
53 * v
54 * STATE_BLOCK_WRITES
55 * |
56 * v
57 * STATE_ACQUIRE_EXCLUSIVE_LOCK (skip if not
58 * | required)
59 * | (disbling journaling)
60 * \-------------------\
61 * | |
62 * | V
63 * | STATE_GET_MIRROR_MODE
64 * |(not |
65 * | disabling v
66 * | journaling) STATE_GET_MIRROR_IMAGE
67 * | |
68 * | v
69 * | STATE_DISABLE_MIRROR_IMAGE (skip if not
70 * | | required)
71 * | v
72 * | STATE_CLOSE_JOURNAL
73 * | |
74 * | v
75 * | STATE_REMOVE_JOURNAL
76 * | |
77 * |/-------------------/
78 * |
79 * v
80 * STATE_APPEND_OP_EVENT (skip if journaling
81 * | disabled)
82 * v
83 * STATE_REMOVE_OBJECT_MAP (skip if not
84 * | disabling object map)
85 * v
86 * STATE_SET_FEATURES
87 * |
88 * v
89 * STATE_UPDATE_FLAGS
90 * |
91 * v
92 * STATE_NOTIFY_UPDATE
93 * |
94 * v
95 * STATE_REALEASE_EXCLUSIVE_LOCK (skip if not
96 * | required)
97 * | (unblock writes)
98 * v
99 * <finish>
100 *
101 * @endverbatim
102 *
103 */
104
105 uint64_t m_features;
106 bool m_force;
107
108 bool m_acquired_lock = false;
109 bool m_writes_blocked = false;
110 bool m_snap_lock_acquired = false;
111 bool m_requests_blocked = false;
112
113 uint64_t m_new_features = 0;
114 uint64_t m_disable_flags = 0;
115 uint64_t m_features_mask = 0;
116
224ce89b 117 decltype(ImageCtxT::journal) m_journal = nullptr;
7c673cae
FG
118 cls::rbd::MirrorMode m_mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
119 bufferlist m_out_bl;
120
121 void send_prepare_lock();
122 Context *handle_prepare_lock(int *result);
123
124 void send_block_writes();
125 Context *handle_block_writes(int *result);
126
127 void send_acquire_exclusive_lock();
128 Context *handle_acquire_exclusive_lock(int *result);
129
130 void send_get_mirror_mode();
131 Context *handle_get_mirror_mode(int *result);
132
133 void send_get_mirror_image();
134 Context *handle_get_mirror_image(int *result);
135
136 void send_disable_mirror_image();
137 Context *handle_disable_mirror_image(int *result);
138
139 void send_close_journal();
140 Context *handle_close_journal(int *result);
141
142 void send_remove_journal();
143 Context *handle_remove_journal(int *result);
144
145 void send_append_op_event();
146 Context *handle_append_op_event(int *result);
147
148 void send_remove_object_map();
149 Context *handle_remove_object_map(int *result);
150
151 void send_set_features();
152 Context *handle_set_features(int *result);
153
154 void send_update_flags();
155 Context *handle_update_flags(int *result);
156
157 void send_notify_update();
158 Context *handle_notify_update(int *result);
159
160 void send_release_exclusive_lock();
161 Context *handle_release_exclusive_lock(int *result);
162
163 Context *handle_finish(int r);
164};
165
166} // namespace operation
167} // namespace librbd
168
169extern template class librbd::operation::DisableFeaturesRequest<librbd::ImageCtx>;
170
171#endif // CEPH_LIBRBD_OPERATION_DISABLE_FEATURES_REQUEST_H