Skip to content

Commit 8c635f5

Browse files
authored
Merge pull request ceph#65134 from xxhdx1985126/wip-seastore-clone-range-latest
crimson/os/seastore: OP_CLONERANGE2 support ---- another approach Reviewed-by: Samuel Just <[email protected]>
2 parents c452120 + a9fdbb7 commit 8c635f5

File tree

18 files changed

+948
-184
lines changed

18 files changed

+948
-184
lines changed

qa/suites/crimson-rados/thrash_simple/thrashers/simple.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ tasks:
2525
sighup_delay: 0
2626
min_in: 3
2727
noscrub_toggle_delay: 0
28-
chance_down: 0
2928
chance_thrash_pg_upmap: 0
3029
reweight_osd: 0
3130
thrash_primary_affinity: false

src/crimson/os/seastore/lba/btree_lba_manager.cc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,17 +427,21 @@ BtreeLBAManager::clone_mapping(
427427
LBAMapping pos,
428428
LBAMapping mapping,
429429
laddr_t laddr,
430+
extent_len_t offset,
431+
extent_len_t len,
430432
bool updateref)
431433
{
432434
LOG_PREFIX(BtreeLBAManager::clone_mapping);
433435
assert(pos.is_viewable());
434436
assert(mapping.is_viewable());
435-
DEBUGT("pos={}, mapping={}, laddr={}, updateref={}",
436-
t, pos, mapping, laddr, updateref);
437+
DEBUGT("pos={}, mapping={}, laddr={}, {}~{} updateref={}",
438+
t, pos, mapping, laddr, offset, len, updateref);
439+
assert(offset + len <= mapping.get_length());
437440
struct state_t {
438441
LBAMapping pos;
439442
LBAMapping mapping;
440443
laddr_t laddr;
444+
extent_len_t offset;
441445
extent_len_t len;
442446
};
443447
auto c = get_context(t);
@@ -464,11 +468,10 @@ BtreeLBAManager::clone_mapping(
464468
return update_refcount_iertr::make_ready_future<
465469
LBAMapping>(std::move(mapping));
466470
}
467-
}).si_then([c, this, pos=std::move(pos),
468-
laddr](auto mapping) mutable {
469-
auto len = mapping.get_length();
471+
}).si_then([c, this, pos=std::move(pos), len,
472+
offset, laddr](auto mapping) mutable {
470473
return seastar::do_with(
471-
state_t{std::move(pos), std::move(mapping), laddr, len},
474+
state_t{std::move(pos), std::move(mapping), laddr, offset, len},
472475
[this, c](auto &state) {
473476
return with_btree<LBABtree>(
474477
cache,
@@ -479,17 +482,15 @@ BtreeLBAManager::clone_mapping(
479482
).si_then([&state, c, &btree]() mutable {
480483
auto &cursor = state.pos.get_effective_cursor();
481484
assert(state.laddr + state.len <= cursor.key);
485+
auto inter_key = state.mapping.is_indirect()
486+
? state.mapping.get_intermediate_key()
487+
: state.mapping.get_key();
488+
inter_key = (inter_key + state.offset).checked_to_laddr();
482489
return btree.insert(
483490
c,
484491
btree.make_partial_iter(c, cursor),
485492
state.laddr,
486-
lba_map_val_t{
487-
state.len,
488-
state.mapping.is_indirect()
489-
? state.mapping.get_intermediate_key()
490-
: state.mapping.get_key(),
491-
EXTENT_DEFAULT_REF_COUNT,
492-
0});
493+
lba_map_val_t{state.len, inter_key, EXTENT_DEFAULT_REF_COUNT, 0});
493494
}).si_then([c, &state](auto p) {
494495
auto &[iter, inserted] = p;
495496
auto &leaf_node = *iter.get_leaf_node();

src/crimson/os/seastore/lba/btree_lba_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class BtreeLBAManager : public LBAManager {
105105
LBAMapping pos,
106106
LBAMapping mapping,
107107
laddr_t laddr,
108+
extent_len_t offset,
109+
extent_len_t len,
108110
bool updateref) final;
109111

110112
#ifdef UNIT_TESTS_BUILT

src/crimson/os/seastore/lba_manager.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,19 @@ class LBAManager {
117117
using clone_mapping_iertr = alloc_extent_iertr;
118118
using clone_mapping_ret = clone_mapping_iertr::future<clone_mapping_ret_t>;
119119
/*
120-
* Clones "mapping" at the position "pos" with new laddr "laddr", if updateref
121-
* is true, update the refcount of the mapping "mapping"
120+
* Clones (part of) "mapping" at the position "pos" with the new lba key "laddr".
122121
*/
123122
virtual clone_mapping_ret clone_mapping(
124123
Transaction &t,
125-
LBAMapping pos,
126-
LBAMapping mapping,
127-
laddr_t laddr,
128-
bool updateref) = 0;
124+
LBAMapping pos, // the destined position
125+
LBAMapping mapping, // the mapping to be cloned
126+
laddr_t laddr, // the new lba key of the cloned mapping
127+
extent_len_t offset, // the offset of the part to be cloned,
128+
// relative to the start of the mapping.
129+
extent_len_t len, // the length of the part to be cloned
130+
bool updateref // whether to update the refcount of the
131+
// direct mapping
132+
) = 0;
129133

130134
virtual alloc_extent_ret reserve_region(
131135
Transaction &t,

src/crimson/os/seastore/lba_mapping.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class LBAMapping {
111111
bool is_zero_reserved() const {
112112
return !is_indirect() && get_val().is_zero();
113113
}
114+
// true if the mapping corresponds to real data
114115
bool is_real() const {
115116
return !is_indirect() && !get_val().is_zero();
116117
}
@@ -147,6 +148,10 @@ class LBAMapping {
147148
return direct_cursor->get_laddr();
148149
}
149150

151+
laddr_t get_end() const {
152+
return (get_key() + get_length()).checked_to_laddr();
153+
}
154+
150155
// An lba pin may be indirect, see comments in lba/btree_lba_manager.h
151156
laddr_t get_intermediate_key() const {
152157
assert(is_indirect());

0 commit comments

Comments
 (0)