]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/journal/ObjectDispatch.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / journal / ObjectDispatch.h
CommitLineData
11fdf7f2
TL
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"
11fdf7f2
TL
10#include "common/zipkin_trace.h"
11#include "librbd/io/Types.h"
12#include "librbd/io/ObjectDispatchInterface.h"
13
14struct Context;
15
16namespace librbd {
17
18struct ImageCtx;
19template <typename> class Journal;
20
21namespace journal {
22
23template <typename ImageCtxT = librbd::ImageCtx>
24class ObjectDispatch : public io::ObjectDispatchInterface {
25public:
26 static ObjectDispatch* create(ImageCtxT* image_ctx,
27 Journal<ImageCtxT>* journal) {
28 return new ObjectDispatch(image_ctx, journal);
29 }
30
31 ObjectDispatch(ImageCtxT* image_ctx, Journal<ImageCtxT>* journal);
32
f67539c2 33 io::ObjectDispatchLayer get_dispatch_layer() const override {
11fdf7f2
TL
34 return io::OBJECT_DISPATCH_LAYER_JOURNAL;
35 }
36
37 void shut_down(Context* on_finish) override;
38
39 bool read(
f67539c2
TL
40 uint64_t object_no, io::ReadExtents* extents, IOContext io_context,
41 int op_flags, int read_flags, const ZTracer::Trace &parent_trace,
42 uint64_t* version, int* object_dispatch_flags,
11fdf7f2
TL
43 io::DispatchResult* dispatch_result, Context** on_finish,
44 Context* on_dispatched) {
45 return false;
46 }
47
48 bool discard(
9f95a23c 49 uint64_t object_no, uint64_t object_off, uint64_t object_len,
f67539c2 50 IOContext io_context, int discard_flags,
11fdf7f2
TL
51 const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
52 uint64_t* journal_tid, io::DispatchResult* dispatch_result,
53 Context** on_finish, Context* on_dispatched) override;
54
55 bool write(
9f95a23c 56 uint64_t object_no, uint64_t object_off, ceph::bufferlist&& data,
f67539c2
TL
57 IOContext io_context, int op_flags, int write_flags,
58 std::optional<uint64_t> assert_version,
11fdf7f2
TL
59 const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
60 uint64_t* journal_tid, io::DispatchResult* dispatch_result,
61 Context** on_finish, Context* on_dispatched) override;
62
63 bool write_same(
9f95a23c
TL
64 uint64_t object_no, uint64_t object_off, uint64_t object_len,
65 io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
f67539c2 66 IOContext io_context, int op_flags,
11fdf7f2
TL
67 const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
68 uint64_t* journal_tid, io::DispatchResult* dispatch_result,
69 Context** on_finish, Context* on_dispatched) override;
70
71 bool compare_and_write(
9f95a23c 72 uint64_t object_no, uint64_t object_off, ceph::bufferlist&& cmp_data,
f67539c2 73 ceph::bufferlist&& write_data, IOContext io_context, int op_flags,
11fdf7f2
TL
74 const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset,
75 int* object_dispatch_flags, uint64_t* journal_tid,
76 io::DispatchResult* dispatch_result, Context** on_finish,
77 Context* on_dispatched) override;
78
79 bool flush(
80 io::FlushSource flush_source, const ZTracer::Trace &parent_trace,
9f95a23c
TL
81 uint64_t* journal_tid, io::DispatchResult* dispatch_result,
82 Context** on_finish, Context* on_dispatched) override;
11fdf7f2 83
f67539c2
TL
84 bool list_snaps(
85 uint64_t object_no, io::Extents&& extents, io::SnapIds&& snap_ids,
86 int list_snap_flags, const ZTracer::Trace &parent_trace,
87 io::SnapshotDelta* snapshot_delta, int* object_dispatch_flags,
88 io::DispatchResult* dispatch_result, Context** on_finish,
89 Context* on_dispatched) override {
90 return false;
91 }
92
11fdf7f2
TL
93 bool invalidate_cache(Context* on_finish) override {
94 return false;
95 }
96 bool reset_existence_cache(Context* on_finish) override {
97 return false;
98 }
99
100 void extent_overwritten(
101 uint64_t object_no, uint64_t object_off, uint64_t object_len,
102 uint64_t journal_tid, uint64_t new_journal_tid) override;
103
f67539c2
TL
104 int prepare_copyup(
105 uint64_t object_no,
106 io::SnapshotSparseBufferlist* snapshot_sparse_bufferlist) override {
107 return 0;
108 }
109
11fdf7f2
TL
110private:
111 ImageCtxT* m_image_ctx;
112 Journal<ImageCtxT>* m_journal;
113
114 void wait_or_flush_event(uint64_t journal_tid, int object_dispatch_flags,
115 Context* on_dispatched);
116
117};
118
119} // namespace journal
120} // namespace librbd
121
122extern template class librbd::journal::ObjectDispatch<librbd::ImageCtx>;
123
124#endif // CEPH_LIBRBD_JOURNAL_OBJECT_DISPATCH_H