1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H
5 #define CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H
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 "librbd/io/ReadResult.h"
12 #include "librbd/io/Types.h"
13 #include "librbd/plugin/Api.h"
23 namespace pwl
{ template <typename
> class AbstractWriteLog
; }
25 template <typename ImageCtxT
>
26 class WriteLogImageDispatch
: public io::ImageDispatchInterface
{
28 WriteLogImageDispatch(ImageCtxT
* image_ctx
,
29 pwl::AbstractWriteLog
<ImageCtx
> *image_cache
,
30 plugin::Api
<ImageCtxT
>& plugin_api
) :
31 m_image_ctx(image_ctx
), m_image_cache(image_cache
),
32 m_plugin_api(plugin_api
) {
35 io::ImageDispatchLayer
get_dispatch_layer() const override
{
36 return io::IMAGE_DISPATCH_LAYER_WRITEBACK_CACHE
;
39 void shut_down(Context
* on_finish
) override
;
42 io::AioCompletion
* aio_comp
, io::Extents
&&image_extents
,
43 io::ReadResult
&&read_result
, IOContext io_context
,
44 int op_flags
, int read_flags
,
45 const ZTracer::Trace
&parent_trace
, uint64_t tid
,
46 std::atomic
<uint32_t>* image_dispatch_flags
,
47 io::DispatchResult
* dispatch_result
, Context
** on_finish
,
48 Context
* on_dispatched
) override
;
50 io::AioCompletion
* aio_comp
, io::Extents
&&image_extents
, bufferlist
&&bl
,
51 IOContext io_context
, int op_flags
, const ZTracer::Trace
&parent_trace
,
52 uint64_t tid
, std::atomic
<uint32_t>* image_dispatch_flags
,
53 io::DispatchResult
* dispatch_result
,
54 Context
** on_finish
, Context
* on_dispatched
) override
;
56 io::AioCompletion
* aio_comp
, io::Extents
&&image_extents
,
57 uint32_t discard_granularity_bytes
, IOContext io_context
,
58 const ZTracer::Trace
&parent_trace
, uint64_t tid
,
59 std::atomic
<uint32_t>* image_dispatch_flags
,
60 io::DispatchResult
* dispatch_result
,
61 Context
** on_finish
, Context
* on_dispatched
) override
;
63 io::AioCompletion
* aio_comp
, io::Extents
&&image_extents
, bufferlist
&&bl
,
64 IOContext io_context
, int op_flags
, const ZTracer::Trace
&parent_trace
,
65 uint64_t tid
, std::atomic
<uint32_t>* image_dispatch_flags
,
66 io::DispatchResult
* dispatch_result
,
67 Context
** on_finish
, Context
* on_dispatched
) override
;
68 bool compare_and_write(
69 io::AioCompletion
* aio_comp
, io::Extents
&&image_extents
,
71 bufferlist
&&bl
, uint64_t *mismatch_offset
,
72 IOContext io_context
, int op_flags
,
73 const ZTracer::Trace
&parent_trace
, uint64_t tid
,
74 std::atomic
<uint32_t>* image_dispatch_flags
,
75 io::DispatchResult
* dispatch_result
,
76 Context
** on_finish
, Context
* on_dispatched
) override
;
78 io::AioCompletion
* aio_comp
, io::FlushSource flush_source
,
79 const ZTracer::Trace
&parent_trace
, uint64_t tid
,
80 std::atomic
<uint32_t>* image_dispatch_flags
,
81 io::DispatchResult
* dispatch_result
,
82 Context
** on_finish
, Context
* on_dispatched
) override
;
84 io::AioCompletion
* aio_comp
, io::Extents
&& image_extents
,
85 io::SnapIds
&& snap_ids
, int list_snaps_flags
,
86 io::SnapshotDelta
* snapshot_delta
,
87 const ZTracer::Trace
&parent_trace
, uint64_t tid
,
88 std::atomic
<uint32_t>* image_dispatch_flags
,
89 io::DispatchResult
* dispatch_result
, Context
** on_finish
,
90 Context
* on_dispatched
) override
;
92 bool invalidate_cache(Context
* on_finish
) override
;
95 ImageCtxT
* m_image_ctx
;
96 pwl::AbstractWriteLog
<ImageCtx
> *m_image_cache
;
97 plugin::Api
<ImageCtxT
>& m_plugin_api
;
99 bool preprocess_length(
100 io::AioCompletion
* aio_comp
, io::Extents
&image_extents
) const;
104 } // namespace librbd
106 extern template class librbd::cache::WriteLogImageDispatch
<librbd::ImageCtx
>;
108 #endif // CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H