Skip to content

Commit 0b6561e

Browse files
xxhdx1985126Matan-B
authored andcommitted
crimson/os/seastore: remove child_pos in LBAMapping
Signed-off-by: Xuehan Xu <[email protected]> (cherry picked from commit fa6ed28)
1 parent c0cd12c commit 0b6561e

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ BtreeLBAMapping::get_logical_extent(Transaction &t)
9999
auto k = this->is_indirect()
100100
? this->get_intermediate_base()
101101
: get_key();
102-
auto v = p.template get_child<LogicalChildNode>(ctx.trans, ctx.cache, pos, k);
103-
if (!v.has_child()) {
104-
this->child_pos = v.get_child_pos();
105-
}
106-
return v;
102+
return p.template get_child<LogicalChildNode>(ctx.trans, ctx.cache, pos, k);
107103
}
108104

109105
bool BtreeLBAMapping::is_stable() const

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ class BtreeLBAMapping : public LBAMapping {
8484
raw_val(val.pladdr),
8585
map_val(val),
8686
parent_modifications(parent->modifications)
87-
{
88-
if (!parent->is_pending()) {
89-
this->child_pos = {parent, pos};
90-
}
91-
}
87+
{}
9288

9389
lba_map_val_t get_map_val() const {
9490
return map_val;

src/crimson/os/seastore/lba_mapping.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ class LBAMapping {
8484
virtual get_child_ret_t<lba_manager::btree::LBALeafNode, LogicalChildNode>
8585
get_logical_extent(Transaction &t) = 0;
8686

87-
void link_child(LogicalChildNode *c) {
88-
ceph_assert(child_pos);
89-
child_pos->link_child(c);
90-
}
9187
virtual LBAMappingRef refresh_with_pending_parent() = 0;
9288

9389
// For reserved mappings, the return values are
@@ -112,9 +108,6 @@ class LBAMapping {
112108
extent_len_t len = 0;
113109
fixed_kv_node_meta_t<laddr_t> range;
114110
uint16_t pos = std::numeric_limits<uint16_t>::max();
115-
116-
std::optional<child_pos_t<
117-
lba_manager::btree::LBALeafNode>> child_pos = std::nullopt;
118111
};
119112

120113
std::ostream &operator<<(std::ostream &out, const LBAMapping &rhs);

src/crimson/os/seastore/transaction_manager.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ class TransactionManager : public ExtentCallbackInterface {
311311
return std::move(extent);
312312
});
313313
} else {
314+
auto &r = std::get<0>(ret);
314315
return this->pin_to_extent<T>(
315-
t, std::move(std::get<0>(ret)),
316+
t, std::move(r.mapping), std::move(r.child_pos),
316317
direct_partial_off, partial_len,
317318
std::move(maybe_init));
318319
}
@@ -981,8 +982,13 @@ class TransactionManager : public ExtentCallbackInterface {
981982

982983
shard_stats_t& shard_stats;
983984

985+
using LBALeafNode = lba_manager::btree::LBALeafNode;
986+
struct unlinked_child_t {
987+
LBAMappingRef mapping;
988+
child_pos_t<LBALeafNode> child_pos;
989+
};
984990
template <typename T>
985-
std::variant<LBAMappingRef, get_child_ifut<T>>
991+
std::variant<unlinked_child_t, get_child_ifut<T>>
986992
get_extent_if_linked(
987993
Transaction &t,
988994
LBAMappingRef pin)
@@ -1005,7 +1011,9 @@ class TransactionManager : public ExtentCallbackInterface {
10051011
return extent->template cast<T>();
10061012
});
10071013
} else {
1008-
return pin;
1014+
return unlinked_child_t{
1015+
std::move(pin),
1016+
v.get_child_pos()};
10091017
}
10101018
}
10111019

@@ -1027,7 +1035,7 @@ class TransactionManager : public ExtentCallbackInterface {
10271035
return ext;
10281036
});
10291037
} else {
1030-
return pin_to_extent_by_type(t, std::move(pin), type);
1038+
return pin_to_extent_by_type(t, std::move(pin), v.get_child_pos(), type);
10311039
}
10321040
}
10331041

@@ -1059,6 +1067,7 @@ class TransactionManager : public ExtentCallbackInterface {
10591067
pin_to_extent_ret<T> pin_to_extent(
10601068
Transaction &t,
10611069
LBAMappingRef pin,
1070+
child_pos_t<LBALeafNode> child_pos,
10621071
extent_len_t direct_partial_off,
10631072
extent_len_t partial_len,
10641073
lextent_init_func_t<T> &&maybe_init) {
@@ -1083,14 +1092,15 @@ class TransactionManager : public ExtentCallbackInterface {
10831092
direct_length,
10841093
direct_partial_off,
10851094
partial_len,
1086-
[&pref, maybe_init=std::move(maybe_init)]
1095+
[&pref, maybe_init=std::move(maybe_init),
1096+
child_pos=std::move(child_pos)]
10871097
(T &extent) mutable {
10881098
assert(extent.is_logical());
10891099
assert(!extent.has_laddr());
10901100
assert(!extent.has_been_invalidated());
10911101
assert(!pref.has_been_invalidated());
10921102
assert(pref.get_parent());
1093-
pref.link_child(&extent);
1103+
child_pos.link_child(&extent);
10941104
extent.maybe_set_intermediate_laddr(pref);
10951105
maybe_init(extent);
10961106
extent.set_seen_by_users();
@@ -1140,6 +1150,7 @@ class TransactionManager : public ExtentCallbackInterface {
11401150
pin_to_extent_by_type_ret pin_to_extent_by_type(
11411151
Transaction &t,
11421152
LBAMappingRef pin,
1153+
child_pos_t<LBALeafNode> child_pos,
11431154
extent_types_t type)
11441155
{
11451156
LOG_PREFIX(TransactionManager::pin_to_extent_by_type);
@@ -1163,15 +1174,15 @@ class TransactionManager : public ExtentCallbackInterface {
11631174
pref.get_val(),
11641175
direct_key,
11651176
direct_length,
1166-
[&pref](CachedExtent &extent) mutable {
1177+
[&pref, child_pos=std::move(child_pos)](CachedExtent &extent) mutable {
11671178
assert(extent.is_logical());
11681179
auto &lextent = static_cast<LogicalChildNode&>(extent);
11691180
assert(!lextent.has_laddr());
11701181
assert(!lextent.has_been_invalidated());
11711182
assert(!pref.has_been_invalidated());
11721183
assert(pref.get_parent());
11731184
assert(!pref.get_parent()->is_pending());
1174-
pref.link_child(&lextent);
1185+
child_pos.link_child(&lextent);
11751186
lextent.maybe_set_intermediate_laddr(pref);
11761187
// No change to extent::seen_by_user because this path is only
11771188
// for background cleaning.

0 commit comments

Comments
 (0)