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