Skip to content

Commit 6187425

Browse files
authored
Merge pull request ceph#60654 from cyx1231st/wip-seastore-fine-grained-cache
crimson/os/seastore: support partial read for data extents Reviewed-by: Xuehan Xu <[email protected]> Reviewed-by: Matan Breizman <[email protected]>
2 parents 27fd389 + e4efceb commit 6187425

32 files changed

+1527
-685
lines changed

src/common/options/crimson.yaml.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ options:
105105
- name: seastore_max_data_allocation_size
106106
type: size
107107
level: advanced
108-
desc: Max size in bytes that an extent can be
109-
default: 32_K
108+
desc: Max size in bytes that an extent can be, 0 to disable
109+
default: 0
110110
- name: seastore_cache_lru_size
111111
type: size
112112
level: advanced

src/crimson/common/fixed_kv_node_layout.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,16 @@ class FixedKVNodeLayout {
360360
}
361361

362362

363-
FixedKVNodeLayout(char *buf) :
364-
buf(buf) {}
363+
FixedKVNodeLayout() : buf(nullptr) {}
365364

366365
virtual ~FixedKVNodeLayout() = default;
367366

367+
void set_layout_buf(char *_buf) {
368+
assert(buf == nullptr);
369+
assert(_buf != nullptr);
370+
buf = _buf;
371+
}
372+
368373
const_iterator begin() const {
369374
return const_iterator(
370375
this,

src/crimson/os/seastore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(crimson_seastore_srcs
44
segment_manager.cc
55
segment_manager/ephemeral.cc
66
segment_manager/block.cc
7+
transaction_interruptor.cc
78
transaction_manager.cc
89
transaction.cc
910
cache.cc

src/crimson/os/seastore/backref/btree_backref_manager.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,22 @@ const get_phy_tree_root_node_ret get_phy_tree_root_node<
2828
ceph_assert(backref_root->is_initial_pending()
2929
== root_block->is_pending());
3030
return {true,
31-
trans_intr::make_interruptible(
32-
c.cache.get_extent_viewable_by_trans(c.trans, backref_root))};
31+
c.cache.get_extent_viewable_by_trans(c.trans, backref_root)};
3332
} else if (root_block->is_pending()) {
3433
auto &prior = static_cast<RootBlock&>(*root_block->get_prior_instance());
3534
backref_root = prior.backref_root_node;
3635
if (backref_root) {
3736
return {true,
38-
trans_intr::make_interruptible(
39-
c.cache.get_extent_viewable_by_trans(c.trans, backref_root))};
37+
c.cache.get_extent_viewable_by_trans(c.trans, backref_root)};
4038
} else {
4139
c.cache.account_absent_access(c.trans.get_src());
4240
return {false,
43-
trans_intr::make_interruptible(
44-
Cache::get_extent_ertr::make_ready_future<
45-
CachedExtentRef>())};
41+
Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
4642
}
4743
} else {
4844
c.cache.account_absent_access(c.trans.get_src());
4945
return {false,
50-
trans_intr::make_interruptible(
51-
Cache::get_extent_ertr::make_ready_future<
52-
CachedExtentRef>())};
46+
Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
5347
}
5448
}
5549

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ inline ChildableCachedExtent* get_reserved_ptr() {
3232
template <typename T>
3333
phy_tree_root_t& get_phy_tree_root(root_t& r);
3434

35-
using get_child_iertr =
36-
::crimson::interruptible::interruptible_errorator<
37-
typename trans_intr::condition,
38-
get_child_ertr>;
3935
using get_phy_tree_root_node_ret =
4036
std::pair<bool, get_child_iertr::future<CachedExtentRef>>;
4137

@@ -1501,7 +1497,7 @@ class FixedKVBtree {
15011497
// checking the lba child must be atomic with creating
15021498
// and linking the absent child
15031499
if (v.has_child()) {
1504-
return trans_intr::make_interruptible(std::move(v.get_child_fut())
1500+
return std::move(v.get_child_fut()
15051501
).si_then([on_found=std::move(on_found), node_iter, c,
15061502
parent_entry](auto child) {
15071503
LOG_PREFIX(FixedKVBtree::lookup_internal_level);
@@ -1571,7 +1567,7 @@ class FixedKVBtree {
15711567
// checking the lba child must be atomic with creating
15721568
// and linking the absent child
15731569
if (v.has_child()) {
1574-
return trans_intr::make_interruptible(std::move(v.get_child_fut())
1570+
return std::move(v.get_child_fut()
15751571
).si_then([on_found=std::move(on_found), node_iter, c,
15761572
parent_entry](auto child) {
15771573
LOG_PREFIX(FixedKVBtree::lookup_leaf);
@@ -2126,7 +2122,7 @@ class FixedKVBtree {
21262122
// checking the lba child must be atomic with creating
21272123
// and linking the absent child
21282124
if (v.has_child()) {
2129-
return trans_intr::make_interruptible(std::move(v.get_child_fut())
2125+
return std::move(v.get_child_fut()
21302126
).si_then([do_merge=std::move(do_merge), &pos,
21312127
donor_iter, donor_is_left, c, parent_pos](auto child) {
21322128
LOG_PREFIX(FixedKVBtree::merge_level);

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

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ struct FixedKVNode : ChildableCachedExtent {
165165
: ChildableCachedExtent(std::move(ptr)),
166166
children(capacity, nullptr),
167167
capacity(capacity) {}
168+
// Must be identical with FixedKVNode(capacity, ptr) after on_fully_loaded()
169+
explicit FixedKVNode(uint16_t capacity, extent_len_t length)
170+
: ChildableCachedExtent(length),
171+
children(capacity, nullptr),
172+
capacity(capacity) {}
168173
FixedKVNode(const FixedKVNode &rhs)
169174
: ChildableCachedExtent(rhs),
170175
range(rhs.range),
@@ -708,12 +713,17 @@ struct FixedKVInternalNode
708713
node_size,
709714
node_type_t>;
710715

711-
FixedKVInternalNode(ceph::bufferptr &&ptr)
712-
: FixedKVNode<NODE_KEY>(CAPACITY, std::move(ptr)),
713-
node_layout_t(this->get_bptr().c_str()) {}
716+
explicit FixedKVInternalNode(ceph::bufferptr &&ptr)
717+
: FixedKVNode<NODE_KEY>(CAPACITY, std::move(ptr)) {
718+
this->set_layout_buf(this->get_bptr().c_str());
719+
}
720+
// Must be identical with FixedKVInternalNode(ptr) after on_fully_loaded()
721+
explicit FixedKVInternalNode(extent_len_t length)
722+
: FixedKVNode<NODE_KEY>(CAPACITY, length) {}
714723
FixedKVInternalNode(const FixedKVInternalNode &rhs)
715-
: FixedKVNode<NODE_KEY>(rhs),
716-
node_layout_t(this->get_bptr().c_str()) {}
724+
: FixedKVNode<NODE_KEY>(rhs) {
725+
this->set_layout_buf(this->get_bptr().c_str());
726+
}
717727

718728
bool have_children() const final {
719729
return true;
@@ -985,6 +995,10 @@ struct FixedKVInternalNode
985995
pivot);
986996
}
987997

998+
void on_fully_loaded() final {
999+
this->set_layout_buf(this->get_bptr().c_str());
1000+
}
1001+
9881002
/**
9891003
* Internal relative addresses on read or in memory prior to commit
9901004
* are either record or block relative depending on whether this
@@ -994,8 +1008,7 @@ struct FixedKVInternalNode
9941008
* resolve_relative_addrs fixes up relative internal references
9951009
* based on base.
9961010
*/
997-
void resolve_relative_addrs(paddr_t base)
998-
{
1011+
void resolve_relative_addrs(paddr_t base) final {
9991012
LOG_PREFIX(FixedKVInternalNode::resolve_relative_addrs);
10001013
for (auto i: *this) {
10011014
if (i->get_val().is_relative()) {
@@ -1122,13 +1135,18 @@ struct FixedKVLeafNode
11221135
node_type_t,
11231136
has_children>;
11241137
using base_t = FixedKVNode<NODE_KEY>;
1125-
FixedKVLeafNode(ceph::bufferptr &&ptr)
1126-
: FixedKVNode<NODE_KEY>(has_children ? CAPACITY : 0, std::move(ptr)),
1127-
node_layout_t(this->get_bptr().c_str()) {}
1138+
explicit FixedKVLeafNode(ceph::bufferptr &&ptr)
1139+
: FixedKVNode<NODE_KEY>(has_children ? CAPACITY : 0, std::move(ptr)) {
1140+
this->set_layout_buf(this->get_bptr().c_str());
1141+
}
1142+
// Must be identical with FixedKVLeafNode(ptr) after on_fully_loaded()
1143+
explicit FixedKVLeafNode(extent_len_t length)
1144+
: FixedKVNode<NODE_KEY>(has_children ? CAPACITY : 0, length) {}
11281145
FixedKVLeafNode(const FixedKVLeafNode &rhs)
11291146
: FixedKVNode<NODE_KEY>(rhs),
1130-
node_layout_t(this->get_bptr().c_str()),
1131-
modifications(rhs.modifications) {}
1147+
modifications(rhs.modifications) {
1148+
this->set_layout_buf(this->get_bptr().c_str());
1149+
}
11321150

11331151
static constexpr bool do_has_children = has_children;
11341152
// for the stable extent, modifications is always 0;
@@ -1235,6 +1253,10 @@ struct FixedKVLeafNode
12351253
}
12361254
}
12371255

1256+
void on_fully_loaded() final {
1257+
this->set_layout_buf(this->get_bptr().c_str());
1258+
}
1259+
12381260
void prepare_commit() final {
12391261
if constexpr (has_children) {
12401262
if (this->is_initial_pending()) {

0 commit comments

Comments
 (0)