Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / managed_lock / ReleaseRequest.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_RELEASE_REQUEST_H
5 #define CEPH_LIBRBD_MANAGED_LOCK_RELEASE_REQUEST_H
6
7 #include "include/rados/librados.hpp"
8 #include "librbd/watcher/Types.h"
9 #include <string>
10
11 class Context;
12 class ContextWQ;
13
14 namespace librbd {
15
16 class Watcher;
17
18 namespace managed_lock {
19
20 template <typename ImageCtxT>
21 class ReleaseRequest {
22 private:
23   typedef watcher::Traits<ImageCtxT> TypeTraits;
24   typedef typename TypeTraits::Watcher Watcher;
25
26 public:
27   static ReleaseRequest* create(librados::IoCtx& ioctx, Watcher *watcher,
28                                 ContextWQ *work_queue,
29                                 const std::string& oid,
30                                 const std::string& cookie,
31                                 Context *on_finish);
32
33   ~ReleaseRequest();
34   void send();
35
36 private:
37   /**
38    * @verbatim
39    *
40    * <start>
41    *    |
42    *    v
43    * UNLOCK
44    *    |
45    *    v
46    * <finish>
47    *
48    * @endverbatim
49    */
50
51   ReleaseRequest(librados::IoCtx& ioctx, Watcher *watcher,
52                  ContextWQ *work_queue, const std::string& oid,
53                  const std::string& cookie, Context *on_finish);
54
55   librados::IoCtx& m_ioctx;
56   Watcher *m_watcher;
57   std::string m_oid;
58   std::string m_cookie;
59   Context *m_on_finish;
60
61   void send_unlock();
62   void handle_unlock(int r);
63
64   void finish();
65
66 };
67
68 } // namespace managed_lock
69 } // namespace librbd
70
71 #endif // CEPH_LIBRBD_MANAGED_LOCK_RELEASE_REQUEST_H