]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/io/ObjectDispatcher.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / io / ObjectDispatcher.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_IO_OBJECT_DISPATCHER_H
5 #define CEPH_LIBRBD_IO_OBJECT_DISPATCHER_H
6
7 #include "include/int_types.h"
8 #include "common/ceph_mutex.h"
9 #include "librbd/io/Types.h"
10 #include <map>
11
12 struct AsyncOpTracker;
13 struct Context;
14
15 namespace librbd {
16
17 struct ImageCtx;
18
19 namespace io {
20
21 struct ObjectDispatchInterface;
22 struct ObjectDispatchSpec;
23
24 struct ObjectDispatcherInterface {
25 public:
26 virtual ~ObjectDispatcherInterface() {
27 }
28
29 private:
30 friend class ObjectDispatchSpec;
31
32 virtual void send(ObjectDispatchSpec* object_dispatch_spec) = 0;
33 };
34
35 template <typename ImageCtxT = ImageCtx>
36 class ObjectDispatcher : public ObjectDispatcherInterface {
37 public:
38 ObjectDispatcher(ImageCtxT* image_ctx);
39 ~ObjectDispatcher();
40
41 void shut_down(Context* on_finish);
42
43 void register_object_dispatch(ObjectDispatchInterface* object_dispatch);
44 void shut_down_object_dispatch(ObjectDispatchLayer object_dispatch_layer,
45 Context* on_finish);
46
47 void invalidate_cache(Context* on_finish);
48 void reset_existence_cache(Context* on_finish);
49
50 void extent_overwritten(
51 uint64_t object_no, uint64_t object_off, uint64_t object_len,
52 uint64_t journal_tid, uint64_t new_journal_tid);
53
54 private:
55 struct ObjectDispatchMeta {
56 ObjectDispatchInterface* object_dispatch = nullptr;
57 AsyncOpTracker* async_op_tracker = nullptr;
58
59 ObjectDispatchMeta() {
60 }
61 ObjectDispatchMeta(ObjectDispatchInterface* object_dispatch,
62 AsyncOpTracker* async_op_tracker)
63 : object_dispatch(object_dispatch), async_op_tracker(async_op_tracker) {
64 }
65 };
66
67 struct C_LayerIterator;
68 struct C_InvalidateCache;
69 struct C_ResetExistenceCache;
70 struct SendVisitor;
71
72 ImageCtxT* m_image_ctx;
73
74 ceph::shared_mutex m_lock;
75 std::map<ObjectDispatchLayer, ObjectDispatchMeta> m_object_dispatches;
76
77 void send(ObjectDispatchSpec* object_dispatch_spec);
78
79 void shut_down_object_dispatch(ObjectDispatchMeta& object_dispatch_meta,
80 Context** on_finish);
81
82 };
83
84 } // namespace io
85 } // namespace librbd
86
87 extern template class librbd::io::ObjectDispatcher<librbd::ImageCtx>;
88
89 #endif // CEPH_LIBRBD_IO_OBJECT_DISPATCHER_H