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_MIRROR_DISABLE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_DISABLE_REQUEST_H
7 #include "include/buffer.h"
8 #include "common/Mutex.h"
9 #include "cls/journal/cls_journal_types.h"
10 #include "cls/rbd/cls_rbd_types.h"
22 template <typename ImageCtxT = ImageCtx>
23 class DisableRequest {
25 static DisableRequest *create(ImageCtxT *image_ctx, bool force,
26 bool remove, Context *on_finish) {
27 return new DisableRequest(image_ctx, force, remove, on_finish);
30 DisableRequest(ImageCtxT *image_ctx, bool force, bool remove,
42 * GET_MIRROR_IMAGE * * * * * * * * * * * * * * * * * * * * * * *
45 * GET_TAG_OWNER * * * * * * * * * * * * * * * * * * * * * * * *
48 * SET_MIRROR_IMAGE * * * * * * * * * * * * * * * * * * * * * * *
51 * NOTIFY_MIRRORING_WATCHER *
54 * PROMOTE_IMAGE (skip if primary) *
57 * GET_CLIENTS <----------------------------------------\ * * * *
58 * | | (unregister clients) | * (on error)
59 * | |/----------------------------\ | *
61 * | | /-----------\ (repeat | (repeat | (repeat
62 * | | | | as needed) | as needed) | as needed)
64 * | REMOVE_SYNC_SNAP --/ * * * * * * | * * * * * * | * * * *
67 * | UNREGISTER_CLIENT ---------------/-------------/ * * * *
69 * | (no more clients *
72 * REMOVE_MIRROR_IMAGE * * * * * * * * * * * * * * * * * * * * *
73 * | (skip if no remove) *
75 * NOTIFY_MIRRORING_WATCHER_REMOVED *
76 * | (skip if not primary or no remove) *
78 * <finish> < * * * * * * * * * * * * * * * * * * * * * * * * * *
83 ImageCtxT *m_image_ctx;
88 bool m_is_primary = false;
90 cls::rbd::MirrorImage m_mirror_image;
91 std::set<cls::journal::Client> m_clients;
92 std::map<std::string, int> m_ret;
93 std::map<std::string, int> m_current_ops;
94 int m_error_result = 0;
97 void send_get_mirror_image();
98 Context *handle_get_mirror_image(int *result);
100 void send_get_tag_owner();
101 Context *handle_get_tag_owner(int *result);
103 void send_set_mirror_image();
104 Context *handle_set_mirror_image(int *result);
106 void send_notify_mirroring_watcher();
107 Context *handle_notify_mirroring_watcher(int *result);
109 void send_promote_image();
110 Context *handle_promote_image(int *result);
112 void send_get_clients();
113 Context *handle_get_clients(int *result);
115 void send_remove_snap(const std::string &client_id,
116 const cls::rbd::SnapshotNamespace &snap_namespace,
117 const std::string &snap_name);
118 Context *handle_remove_snap(int *result, const std::string &client_id);
120 void send_unregister_client(const std::string &client_id);
121 Context *handle_unregister_client(int *result, const std::string &client_id);
123 void send_remove_mirror_image();
124 Context *handle_remove_mirror_image(int *result);
126 void send_notify_mirroring_watcher_removed();
127 Context *handle_notify_mirroring_watcher_removed(int *result);
129 Context *create_context_callback(
130 Context*(DisableRequest<ImageCtxT>::*handle)(
131 int*, const std::string &client_id),
132 const std::string &client_id);
136 } // namespace mirror
137 } // namespace librbd
139 extern template class librbd::mirror::DisableRequest<librbd::ImageCtx>;
141 #endif // CEPH_LIBRBD_MIRROR_DISABLE_REQUEST_H