]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/io/RefreshImageDispatch.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / io / RefreshImageDispatch.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_REFRESH_IMAGE_DISPATCH_H
5 #define CEPH_LIBRBD_IO_REFRESH_IMAGE_DISPATCH_H
6
7 #include "librbd/io/ImageDispatchInterface.h"
8 #include "include/int_types.h"
9 #include "include/buffer.h"
10 #include "common/zipkin_trace.h"
11 #include "common/Throttle.h"
12 #include "librbd/io/ReadResult.h"
13 #include "librbd/io/Types.h"
14
15 struct Context;
16
17 namespace librbd {
18
19 struct ImageCtx;
20
21 namespace io {
22
23 struct AioCompletion;
24
25 template <typename ImageCtxT>
26 class RefreshImageDispatch : public ImageDispatchInterface {
27 public:
28 RefreshImageDispatch(ImageCtxT* image_ctx);
29
30 ImageDispatchLayer get_dispatch_layer() const override {
31 return IMAGE_DISPATCH_LAYER_REFRESH;
32 }
33
34 void shut_down(Context* on_finish) override;
35
36 bool read(
37 AioCompletion* aio_comp, Extents &&image_extents,
38 ReadResult &&read_result, IOContext io_context, int op_flags,
39 int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
40 std::atomic<uint32_t>* image_dispatch_flags,
41 DispatchResult* dispatch_result, Context** on_finish,
42 Context* on_dispatched) override;
43 bool write(
44 AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
45 int op_flags, const ZTracer::Trace &parent_trace,
46 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
47 DispatchResult* dispatch_result, Context** on_finish,
48 Context* on_dispatched) override;
49 bool discard(
50 AioCompletion* aio_comp, Extents &&image_extents,
51 uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
52 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
53 DispatchResult* dispatch_result, Context** on_finish,
54 Context* on_dispatched) override;
55 bool write_same(
56 AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
57 int op_flags, const ZTracer::Trace &parent_trace,
58 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
59 DispatchResult* dispatch_result, Context** on_finish,
60 Context* on_dispatched) override;
61 bool compare_and_write(
62 AioCompletion* aio_comp, Extents &&image_extents,
63 bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset,
64 int op_flags, const ZTracer::Trace &parent_trace,
65 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
66 DispatchResult* dispatch_result, Context** on_finish,
67 Context* on_dispatched) override;
68 bool flush(
69 AioCompletion* aio_comp, FlushSource flush_source,
70 const ZTracer::Trace &parent_trace, uint64_t tid,
71 std::atomic<uint32_t>* image_dispatch_flags,
72 DispatchResult* dispatch_result, Context** on_finish,
73 Context* on_dispatched) override;
74
75 bool list_snaps(
76 AioCompletion* aio_comp, Extents&& image_extents, SnapIds&& snap_ids,
77 int list_snaps_flags, SnapshotDelta* snapshot_delta,
78 const ZTracer::Trace &parent_trace, uint64_t tid,
79 std::atomic<uint32_t>* image_dispatch_flags,
80 DispatchResult* dispatch_result, Context** on_finish,
81 Context* on_dispatched) override {
82 return false;
83 }
84
85 bool invalidate_cache(Context* on_finish) override {
86 return false;
87 }
88
89 private:
90 ImageCtxT* m_image_ctx;
91
92 bool needs_refresh(DispatchResult* dispatch_result, Context* on_dispatched);
93
94 };
95
96 } // namespace io
97 } // namespace librbd
98
99 extern template class librbd::io::RefreshImageDispatch<librbd::ImageCtx>;
100
101 #endif // CEPH_LIBRBD_IO_REFRESH_IMAGE_DISPATCH_H