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_CACHE_OBJECT_CACHER_OBJECT_DISPATCH_H
5 #define CEPH_LIBRBD_CACHE_OBJECT_CACHER_OBJECT_DISPATCH_H
7 #include "librbd/io/ObjectDispatchInterface.h"
8 #include "common/Mutex.h"
9 #include "osdc/ObjectCacher.h"
11 struct WritebackHandler
;
20 * Facade around the OSDC object cacher to make it align with
21 * the object dispatcher interface
23 template <typename ImageCtxT
= ImageCtx
>
24 class ObjectCacherObjectDispatch
: public io::ObjectDispatchInterface
{
26 static ObjectCacherObjectDispatch
* create(ImageCtxT
* image_ctx
) {
27 return new ObjectCacherObjectDispatch(image_ctx
);
30 ObjectCacherObjectDispatch(ImageCtxT
* image_ctx
);
31 ~ObjectCacherObjectDispatch() override
;
33 io::ObjectDispatchLayer
get_object_dispatch_layer() const override
{
34 return io::OBJECT_DISPATCH_LAYER_CACHE
;
38 void shut_down(Context
* on_finish
) override
;
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
) override
;
49 const std::string
&oid
, uint64_t object_no
, uint64_t object_off
,
50 uint64_t object_len
, const ::SnapContext
&snapc
, int discard_flags
,
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
;
56 const std::string
&oid
, uint64_t object_no
, uint64_t object_off
,
57 ceph::bufferlist
&& data
, const ::SnapContext
&snapc
, int op_flags
,
58 const ZTracer::Trace
&parent_trace
, int* object_dispatch_flags
,
59 uint64_t* journal_tid
, io::DispatchResult
* dispatch_result
,
60 Context
** on_finish
, Context
* on_dispatched
) override
;
63 const std::string
&oid
, uint64_t object_no
, uint64_t object_off
,
64 uint64_t object_len
, io::Extents
&& buffer_extents
,
65 ceph::bufferlist
&& data
, const ::SnapContext
&snapc
, int op_flags
,
66 const ZTracer::Trace
&parent_trace
, int* object_dispatch_flags
,
67 uint64_t* journal_tid
, io::DispatchResult
* dispatch_result
,
68 Context
** on_finish
, Context
* on_dispatched
) override
;
70 bool compare_and_write(
71 const std::string
&oid
, uint64_t object_no
, uint64_t object_off
,
72 ceph::bufferlist
&& cmp_data
, ceph::bufferlist
&& write_data
,
73 const ::SnapContext
&snapc
, int op_flags
,
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
;
80 io::FlushSource flush_source
, const ZTracer::Trace
&parent_trace
,
81 io::DispatchResult
* dispatch_result
, Context
** on_finish
,
82 Context
* on_dispatched
) override
;
84 bool invalidate_cache(Context
* on_finish
) override
;
85 bool reset_existence_cache(Context
* on_finish
) override
;
87 void extent_overwritten(
88 uint64_t object_no
, uint64_t object_off
, uint64_t object_len
,
89 uint64_t journal_tid
, uint64_t new_journal_tid
) {
93 struct C_InvalidateCache
;
95 ImageCtxT
* m_image_ctx
;
98 ObjectCacher
*m_object_cacher
= nullptr;
99 ObjectCacher::ObjectSet
*m_object_set
= nullptr;
101 WritebackHandler
*m_writeback_handler
= nullptr;
103 bool m_user_flushed
= false;
108 } // namespace librbd
110 extern template class librbd::cache::ObjectCacherObjectDispatch
<librbd::ImageCtx
>;
112 #endif // CEPH_LIBRBD_CACHE_OBJECT_CACHER_OBJECT_DISPATCH_H