]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/watcher/Notifier.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / librbd / watcher / Notifier.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_WATCHER_NOTIFIER_H
5 #define CEPH_LIBRBD_WATCHER_NOTIFIER_H
6
7 #include "include/int_types.h"
8 #include "include/buffer_fwd.h"
9 #include "include/Context.h"
10 #include "include/rados/librados.hpp"
11 #include "common/Mutex.h"
12 #include "common/WorkQueue.h"
13 #include <list>
14
15 namespace librbd {
16
17 namespace watcher {
18
19 struct NotifyResponse;
20
21 class Notifier {
22 public:
23 static const uint64_t NOTIFY_TIMEOUT;
24
25 Notifier(ContextWQ *work_queue, librados::IoCtx &ioctx,
26 const std::string &oid);
27 ~Notifier();
28
29 void flush(Context *on_finish);
30 void notify(bufferlist &bl, NotifyResponse *response, Context *on_finish);
31
32 private:
33 typedef std::list<Context*> Contexts;
34
35 struct C_AioNotify : public Context {
36 Notifier *notifier;
37 NotifyResponse *response;
38 Context *on_finish;
39 bufferlist out_bl;
40
41 C_AioNotify(Notifier *notifier, NotifyResponse *response,
42 Context *on_finish);
43
44 void finish(int r) override;
45 };
46
47 ContextWQ *m_work_queue;
48 librados::IoCtx &m_ioctx;
49 CephContext *m_cct;
50 std::string m_oid;
51
52 Mutex m_aio_notify_lock;
53 size_t m_pending_aio_notifies = 0;
54 Contexts m_aio_notify_flush_ctxs;
55
56 void handle_notify(int r, Context *on_finish);
57
58 };
59
60 } // namespace watcher
61 } // namespace librbd
62
63 #endif // CEPH_LIBRBD_WATCHER_NOTIFIER_H