]>
git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/seastore/object_data_handler.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
9 #include "include/buffer.h"
11 #include "test/crimson/seastore/test_block.h" // TODO
13 #include "crimson/os/seastore/onode.h"
14 #include "crimson/os/seastore/transaction_manager.h"
15 #include "crimson/os/seastore/transaction.h"
17 namespace crimson::os::seastore
{
19 struct ObjectDataBlock
: crimson::os::seastore::LogicalCachedExtent
{
20 using Ref
= TCachedExtentRef
<ObjectDataBlock
>;
22 explicit ObjectDataBlock(ceph::bufferptr
&&ptr
)
23 : LogicalCachedExtent(std::move(ptr
)) {}
24 explicit ObjectDataBlock(const ObjectDataBlock
&other
)
25 : LogicalCachedExtent(other
) {}
26 explicit ObjectDataBlock(extent_len_t length
)
27 : LogicalCachedExtent(length
) {}
29 CachedExtentRef
duplicate_for_write(Transaction
&) final
{
30 return CachedExtentRef(new ObjectDataBlock(*this));
33 static constexpr extent_types_t TYPE
= extent_types_t::OBJECT_DATA_BLOCK
;
34 extent_types_t
get_type() const final
{
38 ceph::bufferlist
get_delta() final
{
39 /* Currently, we always allocate fresh ObjectDataBlock's rather than
40 * mutating existing ones. */
41 ceph_assert(0 == "Should be impossible");
44 void apply_delta(const ceph::bufferlist
&bl
) final
{
46 ceph_assert(0 == "Should be impossible");
49 using ObjectDataBlockRef
= TCachedExtentRef
<ObjectDataBlock
>;
51 class ObjectDataHandler
{
53 using base_iertr
= TransactionManager::base_iertr
;
55 ObjectDataHandler(uint32_t mos
) : max_object_size(mos
) {}
58 TransactionManager
&tm
;
61 Onode
*d_onode
= nullptr; // The desination node in case of clone
64 /// Writes bl to [offset, offset + bl.length())
65 using write_iertr
= base_iertr
;
66 using write_ret
= write_iertr::future
<>;
70 const bufferlist
&bl
);
72 using zero_iertr
= base_iertr
;
73 using zero_ret
= zero_iertr::future
<>;
79 /// Reads data in [offset, offset + len)
80 using read_iertr
= base_iertr
;
81 using read_ret
= read_iertr::future
<bufferlist
>;
87 /// sparse read data, get range interval in [offset, offset + len)
88 using fiemap_iertr
= base_iertr
;
89 using fiemap_ret
= fiemap_iertr::future
<std::map
<uint64_t, uint64_t>>;
95 /// Clears data past offset
96 using truncate_iertr
= base_iertr
;
97 using truncate_ret
= truncate_iertr::future
<>;
98 truncate_ret
truncate(
102 /// Clears data and reservation
103 using clear_iertr
= base_iertr
;
104 using clear_ret
= clear_iertr::future
<>;
105 clear_ret
clear(context_t ctx
);
107 /// Clone data of an Onode
108 using clone_iertr
= base_iertr
;
109 using clone_ret
= clone_iertr::future
<>;
110 clone_ret
clone(context_t ctx
);
113 /// Updates region [_offset, _offset + bl.length) to bl
115 context_t ctx
, ///< [in] ctx
116 laddr_t offset
, ///< [in] write offset
117 extent_len_t len
, ///< [in] len to write, len == bl->length() if bl
118 std::optional
<bufferlist
> &&bl
, ///< [in] buffer to write, empty for zeros
119 lba_pin_list_t
&&pins
///< [in] set of pins overlapping above region
122 /// Ensures object_data reserved region is prepared
123 write_ret
prepare_data_reservation(
125 object_data_t
&object_data
,
128 /// Trims data past size
129 clear_ret
trim_data_reservation(
131 object_data_t
&object_data
,
134 clone_ret
clone_extents(
136 object_data_t
&object_data
,
137 lba_pin_list_t
&pins
,
144 * For now, we allocate a fixed region of laddr space of size max_object_size
145 * for any object. In the future, once we have the ability to remap logical
146 * mappings (necessary for clone), we'll add the ability to grow and shrink
147 * these regions and remove this assumption.
149 const uint32_t max_object_size
= 0;
154 #if FMT_VERSION >= 90000
155 template <> struct fmt::formatter
<crimson::os::seastore::ObjectDataBlock
> : fmt::ostream_formatter
{};