summaryrefslogtreecommitdiffstats
path: root/src/librbd/managed_lock/AcquireRequest.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/librbd/managed_lock/AcquireRequest.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librbd/managed_lock/AcquireRequest.h')
-rw-r--r--src/librbd/managed_lock/AcquireRequest.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/librbd/managed_lock/AcquireRequest.h b/src/librbd/managed_lock/AcquireRequest.h
new file mode 100644
index 00000000..20af0693
--- /dev/null
+++ b/src/librbd/managed_lock/AcquireRequest.h
@@ -0,0 +1,101 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LIBRBD_MANAGED_LOCK_ACQUIRE_REQUEST_H
+#define CEPH_LIBRBD_MANAGED_LOCK_ACQUIRE_REQUEST_H
+
+#include "include/rados/librados.hpp"
+#include "include/int_types.h"
+#include "include/buffer.h"
+#include "msg/msg_types.h"
+#include "librbd/managed_lock/Types.h"
+#include "librbd/watcher/Types.h"
+#include <string>
+
+class Context;
+class ContextWQ;
+
+namespace librbd {
+
+class Watcher;
+
+namespace managed_lock {
+
+template <typename ImageCtxT>
+class AcquireRequest {
+private:
+ typedef watcher::Traits<ImageCtxT> TypeTraits;
+ typedef typename TypeTraits::Watcher Watcher;
+
+public:
+ static AcquireRequest* create(librados::IoCtx& ioctx, Watcher *watcher,
+ ContextWQ *work_queue, const std::string& oid,
+ const std::string& cookie,
+ bool exclusive,
+ bool blacklist_on_break_lock,
+ uint32_t blacklist_expire_seconds,
+ Context *on_finish);
+
+ ~AcquireRequest();
+ void send();
+
+private:
+
+ /**
+ * @verbatim
+ *
+ * <start>
+ * |
+ * v
+ * GET_LOCKER
+ * | ^
+ * | . (EBUSY && no cached locker)
+ * | .
+ * | . (EBUSY && cached locker)
+ * \--> LOCK_IMAGE * * * * * * * * > BREAK_LOCK . . . . .
+ * | ^ | .
+ * | | | (success) .
+ * | \-------------------------/ .
+ * v .
+ * <finish> < . . . . . . . . . . . . . . . . . . .
+ *
+ * @endverbatim
+ */
+
+ AcquireRequest(librados::IoCtx& ioctx, Watcher *watcher,
+ ContextWQ *work_queue, const std::string& oid,
+ const std::string& cookie, bool exclusive,
+ bool blacklist_on_break_lock,
+ uint32_t blacklist_expire_seconds, Context *on_finish);
+
+ librados::IoCtx& m_ioctx;
+ Watcher *m_watcher;
+ CephContext *m_cct;
+ ContextWQ *m_work_queue;
+ std::string m_oid;
+ std::string m_cookie;
+ bool m_exclusive;
+ bool m_blacklist_on_break_lock;
+ uint32_t m_blacklist_expire_seconds;
+ Context *m_on_finish;
+
+ bufferlist m_out_bl;
+
+ Locker m_locker;
+
+ void send_get_locker();
+ void handle_get_locker(int r);
+
+ void send_lock();
+ void handle_lock(int r);
+
+ void send_break_lock();
+ void handle_break_lock(int r);
+
+ void finish(int r);
+};
+
+} // namespace managed_lock
+} // namespace librbd
+
+#endif // CEPH_LIBRBD_MANAGED_LOCK_ACQUIRE_REQUEST_H