]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/managed_lock/BreakRequest.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / managed_lock / BreakRequest.h
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_fwd.h"
9 #include "include/rados/librados_fwd.hpp"
10 #include "msg/msg_types.h"
11 #include <list>
12 #include <string>
13 #include <boost/optional.hpp>
14 #include "librbd/managed_lock/Types.h"
15
16 class Context;
17 class ContextWQ;
18 class obj_watch_t;
19
20 namespace librbd {
21
22 class AsioEngine;
23 class ImageCtx;
24 template <typename> class Journal;
25 namespace asio { struct ContextWQ; }
26
27 namespace managed_lock {
28
29 template <typename ImageCtxT = ImageCtx>
30 class BreakRequest {
31 public:
32 static BreakRequest* create(librados::IoCtx& ioctx,
33 AsioEngine& asio_engine,
34 const std::string& oid, const Locker &locker,
35 bool exclusive, bool blocklist_locker,
36 uint32_t blocklist_expire_seconds,
37 bool force_break_lock, Context *on_finish) {
38 return new BreakRequest(ioctx, asio_engine, oid, locker, exclusive,
39 blocklist_locker, blocklist_expire_seconds,
40 force_break_lock, on_finish);
41 }
42
43 void send();
44
45 private:
46 /**
47 * @verbatim
48 *
49 * <start>
50 * |
51 * v
52 * GET_WATCHERS
53 * |
54 * v
55 * GET_LOCKER
56 * |
57 * v
58 * BLOCKLIST (skip if disabled)
59 * |
60 * v
61 * WAIT_FOR_OSD_MAP
62 * |
63 * v
64 * BREAK_LOCK
65 * |
66 * v
67 * <finish>
68 *
69 * @endvertbatim
70 */
71
72 librados::IoCtx &m_ioctx;
73 CephContext *m_cct;
74 AsioEngine& m_asio_engine;
75 std::string m_oid;
76 Locker m_locker;
77 bool m_exclusive;
78 bool m_blocklist_locker;
79 uint32_t m_blocklist_expire_seconds;
80 bool m_force_break_lock;
81 Context *m_on_finish;
82
83 bufferlist m_out_bl;
84
85 std::list<obj_watch_t> m_watchers;
86 int m_watchers_ret_val;
87
88 Locker m_refreshed_locker;
89
90 BreakRequest(librados::IoCtx& ioctx, AsioEngine& asio_engine,
91 const std::string& oid, const Locker &locker,
92 bool exclusive, bool blocklist_locker,
93 uint32_t blocklist_expire_seconds, bool force_break_lock,
94 Context *on_finish);
95
96 void send_get_watchers();
97 void handle_get_watchers(int r);
98
99 void send_get_locker();
100 void handle_get_locker(int r);
101
102 void send_blocklist();
103 void handle_blocklist(int r);
104
105 void wait_for_osd_map();
106 void handle_wait_for_osd_map(int r);
107
108 void send_break_lock();
109 void handle_break_lock(int r);
110
111 void finish(int r);
112
113 };
114
115 } // namespace managed_lock
116 } // namespace librbd
117
118 extern template class librbd::managed_lock::BreakRequest<librbd::ImageCtx>;
119
120 #endif // CEPH_LIBRBD_MANAGED_LOCK_BREAK_REQUEST_H