]>
Commit | Line | Data |
---|---|---|
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_JOURNAL_OBJECT_DISPATCH_H | |
5 | #define CEPH_LIBRBD_JOURNAL_OBJECT_DISPATCH_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "include/buffer.h" | |
9 | #include "include/rados/librados.hpp" | |
10 | #include "common/snap_types.h" | |
11 | #include "common/zipkin_trace.h" | |
12 | #include "librbd/io/Types.h" | |
13 | #include "librbd/io/ObjectDispatchInterface.h" | |
14 | ||
15 | struct Context; | |
16 | ||
17 | namespace librbd { | |
18 | ||
19 | struct ImageCtx; | |
20 | template <typename> class Journal; | |
21 | ||
22 | namespace journal { | |
23 | ||
24 | template <typename ImageCtxT = librbd::ImageCtx> | |
25 | class ObjectDispatch : public io::ObjectDispatchInterface { | |
26 | public: | |
27 | static ObjectDispatch* create(ImageCtxT* image_ctx, | |
28 | Journal<ImageCtxT>* journal) { | |
29 | return new ObjectDispatch(image_ctx, journal); | |
30 | } | |
31 | ||
32 | ObjectDispatch(ImageCtxT* image_ctx, Journal<ImageCtxT>* journal); | |
33 | ||
34 | io::ObjectDispatchLayer get_object_dispatch_layer() const override { | |
35 | return io::OBJECT_DISPATCH_LAYER_JOURNAL; | |
36 | } | |
37 | ||
38 | void shut_down(Context* on_finish) override; | |
39 | ||
40 | bool read( | |
41 | const std::string &oid, uint64_t object_no, uint64_t object_off, | |
42 | uint64_t object_len, librados::snap_t snap_id, int op_flags, | |
43 | const ZTracer::Trace &parent_trace, ceph::bufferlist* read_data, | |
44 | io::ExtentMap* extent_map, int* object_dispatch_flags, | |
45 | io::DispatchResult* dispatch_result, Context** on_finish, | |
46 | Context* on_dispatched) { | |
47 | return false; | |
48 | } | |
49 | ||
50 | bool discard( | |
51 | const std::string &oid, uint64_t object_no, uint64_t object_off, | |
52 | uint64_t object_len, const ::SnapContext &snapc, int discard_flags, | |
53 | const ZTracer::Trace &parent_trace, int* object_dispatch_flags, | |
54 | uint64_t* journal_tid, io::DispatchResult* dispatch_result, | |
55 | Context** on_finish, Context* on_dispatched) override; | |
56 | ||
57 | bool write( | |
58 | const std::string &oid, uint64_t object_no, uint64_t object_off, | |
59 | ceph::bufferlist&& data, const ::SnapContext &snapc, int op_flags, | |
60 | const ZTracer::Trace &parent_trace, int* object_dispatch_flags, | |
61 | uint64_t* journal_tid, io::DispatchResult* dispatch_result, | |
62 | Context** on_finish, Context* on_dispatched) override; | |
63 | ||
64 | bool write_same( | |
65 | const std::string &oid, uint64_t object_no, uint64_t object_off, | |
66 | uint64_t object_len, io::Extents&& buffer_extents, | |
67 | ceph::bufferlist&& data, const ::SnapContext &snapc, int op_flags, | |
68 | const ZTracer::Trace &parent_trace, int* object_dispatch_flags, | |
69 | uint64_t* journal_tid, io::DispatchResult* dispatch_result, | |
70 | Context** on_finish, Context* on_dispatched) override; | |
71 | ||
72 | bool compare_and_write( | |
73 | const std::string &oid, uint64_t object_no, uint64_t object_off, | |
74 | ceph::bufferlist&& cmp_data, ceph::bufferlist&& write_data, | |
75 | const ::SnapContext &snapc, int op_flags, | |
76 | const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset, | |
77 | int* object_dispatch_flags, uint64_t* journal_tid, | |
78 | io::DispatchResult* dispatch_result, Context** on_finish, | |
79 | Context* on_dispatched) override; | |
80 | ||
81 | bool flush( | |
82 | io::FlushSource flush_source, const ZTracer::Trace &parent_trace, | |
83 | io::DispatchResult* dispatch_result, Context** on_finish, | |
84 | Context* on_dispatched) override { | |
85 | return false; | |
86 | } | |
87 | ||
88 | bool invalidate_cache(Context* on_finish) override { | |
89 | return false; | |
90 | } | |
91 | bool reset_existence_cache(Context* on_finish) override { | |
92 | return false; | |
93 | } | |
94 | ||
95 | void extent_overwritten( | |
96 | uint64_t object_no, uint64_t object_off, uint64_t object_len, | |
97 | uint64_t journal_tid, uint64_t new_journal_tid) override; | |
98 | ||
99 | private: | |
100 | ImageCtxT* m_image_ctx; | |
101 | Journal<ImageCtxT>* m_journal; | |
102 | ||
103 | void wait_or_flush_event(uint64_t journal_tid, int object_dispatch_flags, | |
104 | Context* on_dispatched); | |
105 | ||
106 | }; | |
107 | ||
108 | } // namespace journal | |
109 | } // namespace librbd | |
110 | ||
111 | extern template class librbd::journal::ObjectDispatch<librbd::ImageCtx>; | |
112 | ||
113 | #endif // CEPH_LIBRBD_JOURNAL_OBJECT_DISPATCH_H |