Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / managed_lock / GetLockerRequest.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_GET_LOCKER_REQUEST_H
5 #define CEPH_LIBRBD_MANAGED_LOCK_GET_LOCKER_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "include/buffer.h"
9
10 class Context;
11
12 namespace librados { class IoCtx; }
13
14 namespace librbd {
15
16 struct ImageCtx;
17
18 namespace managed_lock {
19
20 struct Locker;
21
22 template <typename ImageCtxT = ImageCtx>
23 class GetLockerRequest {
24 public:
25   static GetLockerRequest* create(librados::IoCtx& ioctx,
26                                   const std::string& oid, bool exclusive,
27                                   Locker *locker, Context *on_finish) {
28     return new GetLockerRequest(ioctx, oid, exclusive, locker, on_finish);
29   }
30
31   void send();
32
33 private:
34   librados::IoCtx &m_ioctx;
35   CephContext *m_cct;
36   std::string m_oid;
37   bool m_exclusive;
38   Locker *m_locker;
39   Context *m_on_finish;
40
41   bufferlist m_out_bl;
42
43   GetLockerRequest(librados::IoCtx& ioctx, const std::string& oid,
44                    bool exclusive, Locker *locker, Context *on_finish);
45
46   void send_get_lockers();
47   void handle_get_lockers(int r);
48
49   void finish(int r);
50
51 };
52
53 } // namespace managed_lock
54 } // namespace librbd
55
56 extern template class librbd::managed_lock::GetLockerRequest<librbd::ImageCtx>;
57
58 #endif // CEPH_LIBRBD_MANAGED_LOCK_GET_LOCKER_REQUEST_H