Skip to content

Commit 75dca86

Browse files
authored
Merge pull request ceph#57262 from xxhdx1985126/wip-seastore-clone-remap-refcount
crimson/os/seastore/lba_manager: don't increase intermediate mappings' refcount if LBAManager::clone_mapping() is called to remap mappings Reviewed-by: Yingxin Cheng <[email protected]>
2 parents 9969477 + 4b4d04b commit 75dca86

File tree

10 files changed

+358
-264
lines changed

10 files changed

+358
-264
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,8 @@ class FixedKVBtree {
15161516
};
15171517

15181518
auto v = parent->template get_child<internal_node_t>(c, node_iter);
1519+
// checking the lba child must be atomic with creating
1520+
// and linking the absent child
15191521
if (v.has_child()) {
15201522
return v.get_child_fut().safe_then(
15211523
[on_found=std::move(on_found), node_iter, c,
@@ -1584,6 +1586,8 @@ class FixedKVBtree {
15841586
};
15851587

15861588
auto v = parent->template get_child<leaf_node_t>(c, node_iter);
1589+
// checking the lba child must be atomic with creating
1590+
// and linking the absent child
15871591
if (v.has_child()) {
15881592
return v.get_child_fut().safe_then(
15891593
[on_found=std::move(on_found), node_iter, c,
@@ -2137,6 +2141,8 @@ class FixedKVBtree {
21372141
};
21382142

21392143
auto v = parent_pos.node->template get_child<NodeType>(c, donor_iter);
2144+
// checking the lba child must be atomic with creating
2145+
// and linking the absent child
21402146
if (v.has_child()) {
21412147
return v.get_child_fut().safe_then(
21422148
[do_merge=std::move(do_merge), &pos,

src/crimson/os/seastore/cache.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Cache::~Cache()
5858
ceph_assert(extents.empty());
5959
}
6060

61+
// TODO: this method can probably be removed in the future
6162
Cache::retire_extent_ret Cache::retire_extent_addr(
6263
Transaction &t, paddr_t addr, extent_len_t length)
6364
{
@@ -104,6 +105,33 @@ Cache::retire_extent_ret Cache::retire_extent_addr(
104105
return retire_extent_iertr::now();
105106
}
106107

108+
void Cache::retire_absent_extent_addr(
109+
Transaction &t, paddr_t addr, extent_len_t length)
110+
{
111+
#ifndef NDEBUG
112+
CachedExtentRef ext;
113+
auto result = t.get_extent(addr, &ext);
114+
assert(result != Transaction::get_extent_ret::PRESENT
115+
&& result != Transaction::get_extent_ret::RETIRED);
116+
assert(!query_cache(addr, nullptr));
117+
#endif
118+
LOG_PREFIX(Cache::retire_absent_extent_addr);
119+
// add a new placeholder to Cache
120+
ext = CachedExtent::make_cached_extent_ref<
121+
RetiredExtentPlaceholder>(length);
122+
ext->init(CachedExtent::extent_state_t::CLEAN,
123+
addr,
124+
PLACEMENT_HINT_NULL,
125+
NULL_GENERATION,
126+
TRANS_ID_NULL);
127+
DEBUGT("retire {}~{} as placeholder, add extent -- {}",
128+
t, addr, length, *ext);
129+
const auto t_src = t.get_src();
130+
add_extent(ext, &t_src);
131+
t.add_to_read_set(ext);
132+
t.add_to_retired_set(ext);
133+
}
134+
107135
void Cache::dump_contents()
108136
{
109137
LOG_PREFIX(Cache::dump_contents);

src/crimson/os/seastore/cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ class Cache {
246246
retire_extent_ret retire_extent_addr(
247247
Transaction &t, paddr_t addr, extent_len_t length);
248248

249+
void retire_absent_extent_addr(
250+
Transaction &t, paddr_t addr, extent_len_t length);
251+
249252
/**
250253
* get_root
251254
*
@@ -927,7 +930,7 @@ class Cache {
927930
paddr_t remap_paddr,
928931
extent_len_t remap_length,
929932
laddr_t original_laddr,
930-
std::optional<ceph::bufferptr> &&original_bptr) {
933+
std::optional<ceph::bufferptr> &original_bptr) {
931934
LOG_PREFIX(Cache::alloc_remapped_extent);
932935
assert(remap_laddr >= original_laddr);
933936
TCachedExtentRef<T> ext;

src/crimson/os/seastore/lba_manager.h

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ class LBAManager {
124124
*/
125125
virtual ref_ret decref_extent(
126126
Transaction &t,
127-
laddr_t addr,
128-
bool cascade_remove) = 0;
127+
laddr_t addr) = 0;
129128

130129
/**
131130
* Increments ref count on extent
@@ -136,15 +135,34 @@ class LBAManager {
136135
Transaction &t,
137136
laddr_t addr) = 0;
138137

138+
struct remap_entry {
139+
extent_len_t offset;
140+
extent_len_t len;
141+
remap_entry(extent_len_t _offset, extent_len_t _len) {
142+
offset = _offset;
143+
len = _len;
144+
}
145+
};
146+
struct lba_remap_ret_t {
147+
ref_update_result_t ruret;
148+
std::vector<LBAMappingRef> remapped_mappings;
149+
};
150+
using remap_iertr = ref_iertr;
151+
using remap_ret = remap_iertr::future<lba_remap_ret_t>;
152+
139153
/**
140-
* Increments ref count on extent
154+
* remap_mappings
141155
*
142-
* @return returns resulting refcount
156+
* Remap an original mapping into new ones
157+
* Return the old mapping's info and new mappings
143158
*/
144-
virtual ref_ret incref_extent(
159+
virtual remap_ret remap_mappings(
145160
Transaction &t,
146-
laddr_t addr,
147-
int delta) = 0;
161+
LBAMappingRef orig_mapping,
162+
std::vector<remap_entry> remaps,
163+
std::vector<LogicalCachedExtentRef> extents // Required if and only
164+
// if pin isn't indirect
165+
) = 0;
148166

149167
/**
150168
* Should be called after replay on each cached extent.

0 commit comments

Comments
 (0)