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_MANAGED_LOCK_ACQUIRE_REQUEST_H
5 #define CEPH_LIBRBD_MANAGED_LOCK_ACQUIRE_REQUEST_H
7 #include "include/rados/librados.hpp"
8 #include "include/int_types.h"
9 #include "include/buffer.h"
10 #include "msg/msg_types.h"
11 #include "librbd/managed_lock/Types.h"
12 #include "librbd/watcher/Types.h"
22 namespace managed_lock
{
24 template <typename ImageCtxT
>
25 class AcquireRequest
{
27 typedef watcher::Traits
<ImageCtxT
> TypeTraits
;
28 typedef typename
TypeTraits::Watcher Watcher
;
31 static AcquireRequest
* create(librados::IoCtx
& ioctx
, Watcher
*watcher
,
32 ContextWQ
*work_queue
, const std::string
& oid
,
33 const std::string
& cookie
,
35 bool blacklist_on_break_lock
,
36 uint32_t blacklist_expire_seconds
,
52 * | . (EBUSY && no cached locker)
54 * | . (EBUSY && cached locker)
55 * \--> LOCK_IMAGE * * * * * * * * > BREAK_LOCK . . . . .
58 * | \-------------------------/ .
60 * <finish> < . . . . . . . . . . . . . . . . . . .
65 AcquireRequest(librados::IoCtx
& ioctx
, Watcher
*watcher
,
66 ContextWQ
*work_queue
, const std::string
& oid
,
67 const std::string
& cookie
, bool exclusive
,
68 bool blacklist_on_break_lock
,
69 uint32_t blacklist_expire_seconds
, Context
*on_finish
);
71 librados::IoCtx
& m_ioctx
;
74 ContextWQ
*m_work_queue
;
78 bool m_blacklist_on_break_lock
;
79 uint32_t m_blacklist_expire_seconds
;
86 void send_get_locker();
87 void handle_get_locker(int r
);
90 void handle_lock(int r
);
92 void send_break_lock();
93 void handle_break_lock(int r
);
98 } // namespace managed_lock
101 #endif // CEPH_LIBRBD_MANAGED_LOCK_ACQUIRE_REQUEST_H