]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/TrashWatcher.h
import ceph quincy 17.2.1
[ceph.git] / ceph / src / librbd / TrashWatcher.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_TRASH_WATCHER_H
5 #define CEPH_LIBRBD_TRASH_WATCHER_H
6
7 #include "include/int_types.h"
8 #include "include/rados/librados_fwd.hpp"
9 #include "cls/rbd/cls_rbd_types.h"
10 #include "librbd/ImageCtx.h"
11 #include "librbd/Watcher.h"
12 #include "librbd/trash_watcher/Types.h"
13
14 namespace librbd {
15
16 namespace asio { struct ContextWQ; }
17 namespace watcher {
18 namespace util {
19 template <typename> struct HandlePayloadVisitor;
20 } // namespace util
21 } // namespace watcher
22
23 template <typename ImageCtxT = librbd::ImageCtx>
24 class TrashWatcher : public Watcher {
25 friend struct watcher::util::HandlePayloadVisitor<TrashWatcher<ImageCtxT>>;
26 public:
27 TrashWatcher(librados::IoCtx &io_ctx, asio::ContextWQ *work_queue);
28
29 static void notify_image_added(librados::IoCtx &io_ctx,
30 const std::string& image_id,
31 const cls::rbd::TrashImageSpec& spec,
32 Context *on_finish);
33 static void notify_image_removed(librados::IoCtx &io_ctx,
34 const std::string& image_id,
35 Context *on_finish);
36
37 protected:
38 virtual void handle_image_added(const std::string &image_id,
39 const cls::rbd::TrashImageSpec& spec) = 0;
40 virtual void handle_image_removed(const std::string &image_id) = 0;
41
42 private:
43 void handle_notify(uint64_t notify_id, uint64_t handle,
44 uint64_t notifier_id, bufferlist &bl) override;
45
46 bool handle_payload(const trash_watcher::ImageAddedPayload &payload,
47 Context *on_notify_ack);
48 bool handle_payload(const trash_watcher::ImageRemovedPayload &payload,
49 Context *on_notify_ack);
50 bool handle_payload(const trash_watcher::UnknownPayload &payload,
51 Context *on_notify_ack);
52 };
53
54 } // namespace librbd
55
56 extern template class librbd::TrashWatcher<librbd::ImageCtx>;
57
58 #endif // CEPH_LIBRBD_TRASH_WATCHER_H