]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/io/QueueImageDispatch.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / io / QueueImageDispatch.h
CommitLineData
f67539c2
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_IO_QUEUE_IMAGE_DISPATCH_H
5#define CEPH_LIBRBD_IO_QUEUE_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#include <list>
15#include <set>
16
17struct Context;
18
19namespace librbd {
20
21struct ImageCtx;
22
23namespace io {
24
25struct AioCompletion;
26template <typename> class FlushTracker;
27
28template <typename ImageCtxT>
29class QueueImageDispatch : public ImageDispatchInterface {
30public:
31 QueueImageDispatch(ImageCtxT* image_ctx);
32 ~QueueImageDispatch();
33
34 ImageDispatchLayer get_dispatch_layer() const override {
35 return IMAGE_DISPATCH_LAYER_QUEUE;
36 }
37
38 void shut_down(Context* on_finish) override;
39
40 bool read(
41 AioCompletion* aio_comp, Extents &&image_extents,
42 ReadResult &&read_result, IOContext io_context, int op_flags,
43 int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
44 std::atomic<uint32_t>* image_dispatch_flags,
45 DispatchResult* dispatch_result, Context** on_finish,
46 Context* on_dispatched) override;
47 bool write(
48 AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
1e59de90 49 int op_flags, const ZTracer::Trace &parent_trace,
f67539c2
TL
50 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
51 DispatchResult* dispatch_result, Context** on_finish,
52 Context* on_dispatched) override;
53 bool discard(
54 AioCompletion* aio_comp, Extents &&image_extents,
1e59de90
TL
55 uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
56 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
f67539c2
TL
57 DispatchResult* dispatch_result, Context** on_finish,
58 Context* on_dispatched) override;
59 bool write_same(
60 AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
1e59de90 61 int op_flags, const ZTracer::Trace &parent_trace,
f67539c2
TL
62 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
63 DispatchResult* dispatch_result, Context** on_finish,
64 Context* on_dispatched) override;
65 bool compare_and_write(
1e59de90
TL
66 AioCompletion* aio_comp, Extents &&image_extents,
67 bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset,
68 int op_flags, const ZTracer::Trace &parent_trace,
69 uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
f67539c2
TL
70 DispatchResult* dispatch_result, Context** on_finish,
71 Context* on_dispatched) override;
72 bool flush(
73 AioCompletion* aio_comp, FlushSource flush_source,
74 const ZTracer::Trace &parent_trace, uint64_t tid,
75 std::atomic<uint32_t>* image_dispatch_flags,
76 DispatchResult* dispatch_result, Context** on_finish,
77 Context* on_dispatched) override;
78
79 bool list_snaps(
80 AioCompletion* aio_comp, Extents&& image_extents, SnapIds&& snap_ids,
81 int list_snaps_flags, SnapshotDelta* snapshot_delta,
82 const ZTracer::Trace &parent_trace, uint64_t tid,
83 std::atomic<uint32_t>* image_dispatch_flags,
84 DispatchResult* dispatch_result, Context** on_finish,
85 Context* on_dispatched) override {
86 return false;
87 }
88
89 bool invalidate_cache(Context* on_finish) override {
90 return false;
91 }
92
93private:
94 ImageCtxT* m_image_ctx;
95
96 FlushTracker<ImageCtxT>* m_flush_tracker;
97
98 void handle_finished(int r, uint64_t tid);
99
100 bool enqueue(bool read_op, uint64_t tid, DispatchResult* dispatch_result,
101 Context** on_finish, Context* on_dispatched);
102
103};
104
105} // namespace io
106} // namespace librbd
107
108extern template class librbd::io::QueueImageDispatch<librbd::ImageCtx>;
109
110#endif // CEPH_LIBRBD_IO_QUEUE_IMAGE_DISPATCH_H