]>
git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/seastore/onode_manager/staged-fltree/fltree_onode_manager.h
09998fbfaea9f04da2deb73a5f2c4d189829b655
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "crimson/os/seastore/onode_manager.h"
7 #include "crimson/os/seastore/onode_manager/staged-fltree/value.h"
8 #include "crimson/os/seastore/onode_manager/staged-fltree/tree.h"
10 namespace crimson::os::seastore::onode
{
12 struct FLTreeOnode final
: Onode
, Value
{
13 static constexpr tree_conf_t TREE_CONF
= {
16 // same to option osd_max_object_namespace_len
18 // same to option osd_max_object_name_len
19 1200, // max_value_payload_size
20 // see crimson::os::seastore::onode_layout_t
21 8192, // internal_node_size
22 // see the formula in validate_tree_config
23 16384 // leaf_node_size
24 // see the formula in validate_tree_config
31 } status
= status_t::STABLE
;
33 FLTreeOnode(FLTreeOnode
&&) = default;
34 FLTreeOnode
& operator=(FLTreeOnode
&&) = delete;
36 FLTreeOnode(const FLTreeOnode
&) = default;
37 FLTreeOnode
& operator=(const FLTreeOnode
&) = delete;
39 template <typename
... T
>
40 FLTreeOnode(uint32_t ddr
, uint32_t dmr
, T
&&... args
)
42 Value(std::forward
<T
>(args
)...) {}
44 template <typename
... T
>
45 FLTreeOnode(T
&&... args
)
47 Value(std::forward
<T
>(args
)...) {}
49 struct Recorder
: public ValueDeltaRecorder
{
50 Recorder(bufferlist
&bl
) : ValueDeltaRecorder(bl
) {}
52 value_magic_t
get_header_magic() const final
{
53 return TREE_CONF
.value_magic
;
56 void apply_value_delta(
57 ceph::bufferlist::const_iterator
&bliter
,
58 NodeExtentMutable
&value
,
60 assert(value
.get_length() == sizeof(onode_layout_t
));
61 bliter
.copy(value
.get_length(), value
.get_write());
64 void record_delta(NodeExtentMutable
&value
) {
65 // TODO: probably could use versioning, etc
66 assert(value
.get_length() == sizeof(onode_layout_t
));
67 ceph::buffer::ptr
bptr(value
.get_length());
68 memcpy(bptr
.c_str(), value
.get_read(), value
.get_length());
69 get_encoded(value
).append(bptr
);
73 bool is_alive() const {
74 return status
!= status_t::DELETED
;
76 const onode_layout_t
&get_layout() const final
{
77 assert(status
!= status_t::DELETED
);
78 return *read_payload
<onode_layout_t
>();
81 onode_layout_t
&get_mutable_layout(Transaction
&t
) final
{
82 assert(status
!= status_t::DELETED
);
83 auto p
= prepare_mutate_payload
<
86 status
= status_t::MUTATED
;
87 return *reinterpret_cast<onode_layout_t
*>(p
.first
.get_write());
90 void populate_recorder(Transaction
&t
) {
91 assert(status
== status_t::MUTATED
);
92 auto p
= prepare_mutate_payload
<
96 p
.second
->record_delta(
99 status
= status_t::STABLE
;
103 assert(status
!= status_t::DELETED
);
104 status
= status_t::DELETED
;
107 laddr_t
get_hint() const final
{
108 return Value::get_hint();
110 ~FLTreeOnode() final
{}
113 using OnodeTree
= Btree
<FLTreeOnode
>;
115 using crimson::common::get_conf
;
117 class FLTreeOnodeManager
: public crimson::os::seastore::OnodeManager
{
120 uint32_t default_data_reservation
= 0;
121 uint32_t default_metadata_offset
= 0;
122 uint32_t default_metadata_range
= 0;
124 FLTreeOnodeManager(TransactionManager
&tm
) :
125 tree(NodeExtentManager::create_seastore(tm
)),
126 default_data_reservation(
127 get_conf
<uint64_t>("seastore_default_max_object_size")),
128 default_metadata_offset(default_data_reservation
),
129 default_metadata_range(
130 get_conf
<uint64_t>("seastore_default_object_metadata_reservation"))
133 mkfs_ret
mkfs(Transaction
&t
) {
137 contains_onode_ret
contains_onode(
139 const ghobject_t
&hoid
) final
;
141 get_onode_ret
get_onode(
143 const ghobject_t
&hoid
) final
;
145 get_or_create_onode_ret
get_or_create_onode(
147 const ghobject_t
&hoid
) final
;
149 get_or_create_onodes_ret
get_or_create_onodes(
151 const std::vector
<ghobject_t
> &hoids
) final
;
153 write_dirty_ret
write_dirty(
155 const std::vector
<OnodeRef
> &onodes
) final
;
157 erase_onode_ret
erase_onode(
159 OnodeRef
&onode
) final
;
161 list_onodes_ret
list_onodes(
163 const ghobject_t
& start
,
164 const ghobject_t
& end
,
165 uint64_t limit
) final
;
167 ~FLTreeOnodeManager();
169 using FLTreeOnodeManagerRef
= std::unique_ptr
<FLTreeOnodeManager
>;