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_ENABLE_FEATURES_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_ENABLE_FEATURES_REQUEST_H
7 #include "librbd/operation/Request.h"
17 template <typename ImageCtxT = ImageCtx>
18 class EnableFeaturesRequest : public Request<ImageCtxT> {
20 static EnableFeaturesRequest *create(ImageCtxT &image_ctx, Context *on_finish,
21 uint64_t journal_op_tid,
23 return new EnableFeaturesRequest(image_ctx, on_finish, journal_op_tid,
27 EnableFeaturesRequest(ImageCtxT &image_ctx, Context *on_finish,
28 uint64_t journal_op_tid, uint64_t features);
31 void send_op() override;
32 bool should_complete(int r) override;
33 bool can_affect_io() const override {
36 journal::Event create_event(uint64_t op_tid) const override {
37 return journal::UpdateFeaturesEvent(op_tid, m_features, true);
42 * EnableFeatures goes through the following state machine:
55 * STATE_GET_MIRROR_MODE
58 * STATE_CREATE_JOURNAL (skip if not
61 * STATE_APPEND_OP_EVENT (skip if journaling
70 * STATE_CREATE_OBJECT_MAP (skip if not
73 * STATE_ENABLE_MIRROR_IMAGE
87 bool m_enable_mirroring = false;
88 bool m_requests_blocked = false;
89 bool m_writes_blocked = false;
91 uint64_t m_new_features = 0;
92 uint64_t m_enable_flags = 0;
93 uint64_t m_features_mask = 0;
97 void send_prepare_lock();
98 Context *handle_prepare_lock(int *result);
100 void send_block_writes();
101 Context *handle_block_writes(int *result);
103 void send_get_mirror_mode();
104 Context *handle_get_mirror_mode(int *result);
106 void send_create_journal();
107 Context *handle_create_journal(int *result);
109 void send_append_op_event();
110 Context *handle_append_op_event(int *result);
112 void send_update_flags();
113 Context *handle_update_flags(int *result);
115 void send_set_features();
116 Context *handle_set_features(int *result);
118 void send_create_object_map();
119 Context *handle_create_object_map(int *result);
121 void send_enable_mirror_image();
122 Context *handle_enable_mirror_image(int *result);
124 void send_notify_update();
125 Context *handle_notify_update(int *result);
127 Context *handle_finish(int r);
130 } // namespace operation
131 } // namespace librbd
133 extern template class librbd::operation::EnableFeaturesRequest<librbd::ImageCtx>;
135 #endif // CEPH_LIBRBD_OPERATION_ENABLE_FEATURES_REQUEST_H