1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_OPERATION_DISABLE_FEATURES_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_DISABLE_FEATURES_REQUEST_H
7 #include "librbd/ImageCtx.h"
8 #include "librbd/operation/Request.h"
9 #include "cls/rbd/cls_rbd_client.h"
19 template <typename ImageCtxT = ImageCtx>
20 class DisableFeaturesRequest : public Request<ImageCtxT> {
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,
29 DisableFeaturesRequest(ImageCtxT &image_ctx, Context *on_finish,
30 uint64_t journal_op_tid, uint64_t features, bool force);
33 void send_op() override;
34 bool should_complete(int r) override;
35 bool can_affect_io() const override {
38 journal::Event create_event(uint64_t op_tid) const override {
39 return journal::UpdateFeaturesEvent(op_tid, m_features, false);
44 * DisableFeatures goes through the following state machine:
57 * STATE_ACQUIRE_EXCLUSIVE_LOCK (skip if not
59 * | (disbling journaling)
60 * \-------------------\
63 * | STATE_GET_MIRROR_MODE
66 * | journaling) STATE_GET_MIRROR_IMAGE
69 * | STATE_DISABLE_MIRROR_IMAGE (skip if not
72 * | STATE_CLOSE_JOURNAL
75 * | STATE_REMOVE_JOURNAL
77 * |/-------------------/
80 * STATE_APPEND_OP_EVENT (skip if journaling
83 * STATE_REMOVE_OBJECT_MAP (skip if not
84 * | disabling object map)
95 * STATE_REALEASE_EXCLUSIVE_LOCK (skip if not
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;
113 uint64_t m_new_features = 0;
114 uint64_t m_disable_flags = 0;
115 uint64_t m_features_mask = 0;
117 decltype(ImageCtxT::journal) m_journal = nullptr;
118 cls::rbd::MirrorMode m_mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
121 void send_prepare_lock();
122 Context *handle_prepare_lock(int *result);
124 void send_block_writes();
125 Context *handle_block_writes(int *result);
127 void send_acquire_exclusive_lock();
128 Context *handle_acquire_exclusive_lock(int *result);
130 void send_get_mirror_mode();
131 Context *handle_get_mirror_mode(int *result);
133 void send_get_mirror_image();
134 Context *handle_get_mirror_image(int *result);
136 void send_disable_mirror_image();
137 Context *handle_disable_mirror_image(int *result);
139 void send_close_journal();
140 Context *handle_close_journal(int *result);
142 void send_remove_journal();
143 Context *handle_remove_journal(int *result);
145 void send_append_op_event();
146 Context *handle_append_op_event(int *result);
148 void send_remove_object_map();
149 Context *handle_remove_object_map(int *result);
151 void send_set_features();
152 Context *handle_set_features(int *result);
154 void send_update_flags();
155 Context *handle_update_flags(int *result);
157 void send_notify_update();
158 Context *handle_notify_update(int *result);
160 void send_release_exclusive_lock();
161 Context *handle_release_exclusive_lock(int *result);
163 Context *handle_finish(int r);
166 } // namespace operation
167 } // namespace librbd
169 extern template class librbd::operation::DisableFeaturesRequest<librbd::ImageCtx>;
171 #endif // CEPH_LIBRBD_OPERATION_DISABLE_FEATURES_REQUEST_H