]>
Commit | Line | Data |
---|---|---|
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_MANAGED_LOCK_BREAK_REQUEST_H | |
5 | #define CEPH_LIBRBD_MANAGED_LOCK_BREAK_REQUEST_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "include/buffer.h" | |
9 | #include "msg/msg_types.h" | |
10 | #include <list> | |
11 | #include <string> | |
12 | #include <boost/optional.hpp> | |
13 | #include "librbd/managed_lock/Types.h" | |
14 | ||
15 | class Context; | |
16 | class ContextWQ; | |
17 | class obj_watch_t; | |
18 | ||
19 | namespace librados { class IoCtx; } | |
20 | ||
21 | namespace librbd { | |
22 | ||
23 | class ImageCtx; | |
24 | template <typename> class Journal; | |
25 | ||
26 | namespace managed_lock { | |
27 | ||
28 | template <typename ImageCtxT = ImageCtx> | |
29 | class BreakRequest { | |
30 | public: | |
31 | static BreakRequest* create(librados::IoCtx& ioctx, ContextWQ *work_queue, | |
32 | const std::string& oid, const Locker &locker, | |
33 | bool blacklist_locker, | |
34 | uint32_t blacklist_expire_seconds, | |
35 | bool force_break_lock, Context *on_finish) { | |
36 | return new BreakRequest(ioctx, work_queue, oid, locker, blacklist_locker, | |
37 | blacklist_expire_seconds, force_break_lock, | |
38 | on_finish); | |
39 | } | |
40 | ||
41 | void send(); | |
42 | ||
43 | private: | |
44 | /** | |
45 | * @verbatim | |
46 | * | |
47 | * <start> | |
48 | * | | |
49 | * v | |
50 | * GET_WATCHERS | |
51 | * | | |
52 | * v | |
53 | * BLACKLIST (skip if disabled) | |
54 | * | | |
55 | * v | |
56 | * BREAK_LOCK | |
57 | * | | |
58 | * v | |
59 | * <finish> | |
60 | * | |
61 | * @endvertbatim | |
62 | */ | |
63 | ||
64 | librados::IoCtx &m_ioctx; | |
65 | CephContext *m_cct; | |
66 | ContextWQ *m_work_queue; | |
67 | std::string m_oid; | |
68 | Locker m_locker; | |
69 | bool m_blacklist_locker; | |
70 | uint32_t m_blacklist_expire_seconds; | |
71 | bool m_force_break_lock; | |
72 | Context *m_on_finish; | |
73 | ||
74 | bufferlist m_out_bl; | |
75 | ||
76 | std::list<obj_watch_t> m_watchers; | |
77 | int m_watchers_ret_val; | |
78 | ||
79 | BreakRequest(librados::IoCtx& ioctx, ContextWQ *work_queue, | |
80 | const std::string& oid, const Locker &locker, | |
81 | bool blacklist_locker, uint32_t blacklist_expire_seconds, | |
82 | bool force_break_lock, Context *on_finish); | |
83 | ||
84 | void send_get_watchers(); | |
85 | void handle_get_watchers(int r); | |
86 | ||
87 | void send_blacklist(); | |
88 | void handle_blacklist(int r); | |
89 | ||
90 | void send_break_lock(); | |
91 | void handle_break_lock(int r); | |
92 | ||
93 | void finish(int r); | |
94 | ||
95 | }; | |
96 | ||
97 | } // namespace managed_lock | |
98 | } // namespace librbd | |
99 | ||
100 | extern template class librbd::managed_lock::BreakRequest<librbd::ImageCtx>; | |
101 | ||
102 | #endif // CEPH_LIBRBD_MANAGED_LOCK_BREAK_REQUEST_H |