Skip to content

Commit 1e29203

Browse files
authored
Merge pull request ceph#61936 from xxhdx1985126/wip-seastore-omap-tree-pointer
crimson/os/seastore/omap_manager: apply linked tree nodes to omap trees Reviewed-by: Yingxin Cheng <[email protected]>
2 parents 479d6bb + 23cc895 commit 1e29203

18 files changed

+639
-207
lines changed

src/crimson/os/seastore/backref/backref_tree_node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class BackrefInternalNode
9191
"INTERNAL_NODE_CAPACITY doesn't fit in BACKREF_NODE_SIZE");
9292
public:
9393
using key_type = paddr_t;
94+
static constexpr uint32_t CHILD_VEC_UNIT = 0;
9495
template <typename... T>
9596
BackrefInternalNode(T&&... t) :
9697
FixedKVInternalNode(std::forward<T>(t)...) {}

src/crimson/os/seastore/btree/fixed_kv_btree.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,7 @@ class FixedKVBtree {
15031503
return on_found(child->template cast<internal_node_t>());
15041504
});
15051505
}
1506+
c.cache.account_absent_access(c.trans.get_src());
15061507

15071508
auto child_pos = v.get_child_pos();
15081509
auto next_iter = node_iter + 1;
@@ -1574,6 +1575,7 @@ class FixedKVBtree {
15741575
return on_found(child->template cast<leaf_node_t>());
15751576
});
15761577
}
1578+
c.cache.account_absent_access(c.trans.get_src());
15771579

15781580
auto child_pos = v.get_child_pos();
15791581
auto next_iter = node_iter + 1;
@@ -2133,6 +2135,7 @@ class FixedKVBtree {
21332135
return do_merge(child->template cast<NodeType>());
21342136
});
21352137
}
2138+
c.cache.account_absent_access(c.trans.get_src());
21362139

21372140
auto child_pos = v.get_child_pos();
21382141
return get_node<NodeType>(

src/crimson/os/seastore/btree/fixed_kv_node.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ struct FixedKVNode : CachedExtent {
4949
virtual ~FixedKVNode() = default;
5050
virtual void do_on_rewrite(Transaction &t, CachedExtent &extent) = 0;
5151

52+
bool is_in_range(const node_key_t key) const {
53+
return get_node_meta().is_in_range(key);
54+
}
55+
5256
void on_rewrite(Transaction &t, CachedExtent &extent, extent_len_t off) final {
5357
assert(get_type() == extent.get_type());
5458
assert(off == 0);
@@ -139,7 +143,7 @@ struct FixedKVInternalNode
139143
node_size,
140144
node_type_t>;
141145
using parent_node_t = ParentNode<node_type_t, NODE_KEY>;
142-
using base_child_node_t = BaseChildNode<node_type_t, NODE_KEY>;
146+
using base_child_t = BaseChildNode<node_type_t, NODE_KEY>;
143147
using child_node_t = ChildNode<node_type_t, node_type_t, NODE_KEY>;
144148
using root_node_t = RootChildNode<RootBlock, node_type_t>;
145149

@@ -236,7 +240,7 @@ struct FixedKVInternalNode
236240
void update(
237241
internal_const_iterator_t iter,
238242
paddr_t addr,
239-
base_child_node_t* nextent) {
243+
base_child_t* nextent) {
240244
LOG_PREFIX(FixedKVInternalNode::update);
241245
SUBTRACE(seastore_fixedkv_tree, "trans.{}, pos {}, {}",
242246
this->pending_for_transaction,
@@ -253,7 +257,7 @@ struct FixedKVInternalNode
253257
internal_const_iterator_t iter,
254258
NODE_KEY pivot,
255259
paddr_t addr,
256-
base_child_node_t* nextent) {
260+
base_child_t* nextent) {
257261
LOG_PREFIX(FixedKVInternalNode::insert);
258262
SUBTRACE(seastore_fixedkv_tree, "trans.{}, pos {}, key {}, {}",
259263
this->pending_for_transaction,
@@ -284,7 +288,7 @@ struct FixedKVInternalNode
284288
internal_const_iterator_t iter,
285289
NODE_KEY pivot,
286290
paddr_t addr,
287-
base_child_node_t* nextent) {
291+
base_child_t* nextent) {
288292
LOG_PREFIX(FixedKVInternalNode::replace);
289293
SUBTRACE(seastore_fixedkv_tree, "trans.{}, pos {}, old key {}, key {}, {}",
290294
this->pending_for_transaction,
@@ -515,6 +519,7 @@ struct FixedKVLeafNode
515519
using base_t = FixedKVNode<NODE_KEY>;
516520
using child_node_t = ChildNode<internal_node_type_t, node_type_t, NODE_KEY>;
517521
using root_node_t = RootChildNode<RootBlock, node_type_t>;
522+
using base_child_t = BaseChildNode<node_type_t, NODE_KEY>;
518523
explicit FixedKVLeafNode(ceph::bufferptr &&ptr)
519524
: FixedKVNode<NODE_KEY>(std::move(ptr)) {
520525
this->set_layout_buf(this->get_bptr().c_str());

src/crimson/os/seastore/cache.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,14 @@ record_t Cache::prepare_record(
13401340
delta_stat.increment(delta_length);
13411341
}
13421342

1343+
t.for_each_finalized_fresh_block([](auto &e) {
1344+
// fresh blocks' `prepare_commit` must be invoked before
1345+
// retiering extents, this is because logical linked tree
1346+
// nodes needs to access their prior instances in this
1347+
// phase if they are rewritten.
1348+
e->prepare_commit();
1349+
});
1350+
13431351
// Transaction is now a go, set up in-memory cache state
13441352
// invalidate now invalid blocks
13451353
io_stat_t retire_stat;
@@ -1403,7 +1411,6 @@ record_t Cache::prepare_record(
14031411

14041412
bufferlist bl;
14051413
i->prepare_write();
1406-
i->prepare_commit();
14071414
bl.append(i->get_bptr());
14081415
if (is_root_type(i->get_type())) {
14091416
ceph_assert(0 == "ROOT never gets written as a fresh block");
@@ -1457,7 +1464,6 @@ record_t Cache::prepare_record(
14571464
assert(!i->is_inline());
14581465
get_by_ext(efforts.fresh_ool_by_ext,
14591466
i->get_type()).increment(i->get_length());
1460-
i->prepare_commit();
14611467
if (is_backref_mapped_type(i->get_type())) {
14621468
laddr_t alloc_laddr;
14631469
if (i->is_logical()) {

src/crimson/os/seastore/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Cache : public ExtentTransViewRetriever {
186186
return t.root;
187187
}
188188

189-
void account_absent_access(Transaction::src_t src) final {
189+
void account_absent_access(Transaction::src_t src) {
190190
++(get_by_src(stats.cache_absent_by_src, src));
191191
++stats.access.cache_absent;
192192
}

src/crimson/os/seastore/cached_extent.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,12 +1388,15 @@ class LogicalCachedExtent : public CachedExtent {
13881388
template <typename... T>
13891389
LogicalCachedExtent(T&&... t) : CachedExtent(std::forward<T>(t)...) {}
13901390

1391-
void on_rewrite(Transaction&, CachedExtent &extent, extent_len_t off) final {
1391+
void on_rewrite(Transaction &t, CachedExtent &extent, extent_len_t off) final {
13921392
assert(get_type() == extent.get_type());
13931393
auto &lextent = (LogicalCachedExtent&)extent;
13941394
set_laddr((lextent.get_laddr() + off).checked_to_laddr());
1395+
do_on_rewrite(t, lextent);
13951396
}
13961397

1398+
virtual void do_on_rewrite(Transaction &t, LogicalCachedExtent &extent) {}
1399+
13971400
bool has_laddr() const {
13981401
return laddr != L_ADDR_NULL;
13991402
}

src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ BtreeLBAMapping::get_logical_extent(Transaction &t)
103103
: get_key();
104104
auto v = p.template get_child<LogicalChildNode>(ctx.trans, ctx.cache, pos, k);
105105
if (!v.has_child()) {
106+
ctx.cache.account_absent_access(ctx.trans.get_src());
106107
this->child_pos = v.get_child_pos();
107108
}
108109
return v;

src/crimson/os/seastore/lba_manager/btree/lba_btree_node.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct LBAInternalNode
9494
template <typename... T>
9595
LBAInternalNode(T&&... t) :
9696
FixedKVInternalNode(std::forward<T>(t)...) {}
97+
static constexpr uint32_t CHILD_VEC_UNIT = 0;
9798

9899
static constexpr extent_types_t TYPE = extent_types_t::LADDR_INTERNAL;
99100

@@ -173,6 +174,7 @@ struct LBALeafNode
173174
using key_type = laddr_t;
174175
using parent_node_t = ParentNode<LBALeafNode, laddr_t>;
175176
using child_t = LogicalChildNode;
177+
static constexpr uint32_t CHILD_VEC_UNIT = 0;
176178
LBALeafNode(ceph::bufferptr &&ptr)
177179
: parent_type_t(std::move(ptr)),
178180
parent_node_t(LEAF_NODE_CAPACITY) {}

0 commit comments

Comments
 (0)