Skip to content

Commit 25be5fd

Browse files
committed
crimson/os/seastore/transaction_manager: link RetiredExtentPlaceholder
onto lba leaf nodes Signed-off-by: Xuehan Xu <[email protected]>
1 parent 5fbb02a commit 25be5fd

File tree

7 files changed

+261
-149
lines changed

7 files changed

+261
-149
lines changed

src/crimson/os/seastore/cache.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Cache::retire_extent_ret Cache::retire_extent_addr(
9393
return retire_extent_iertr::now();
9494
}
9595

96-
void Cache::retire_absent_extent_addr(
97-
Transaction &t, paddr_t paddr, extent_len_t length)
96+
CachedExtentRef Cache::retire_absent_extent_addr(
97+
Transaction &t, laddr_t laddr, paddr_t paddr, extent_len_t length)
9898
{
9999
assert(paddr.is_absolute());
100100

@@ -112,10 +112,12 @@ void Cache::retire_absent_extent_addr(
112112
ext->init(
113113
CachedExtent::extent_state_t::CLEAN, paddr,
114114
PLACEMENT_HINT_NULL, NULL_GENERATION, TRANS_ID_NULL);
115+
static_cast<RetiredExtentPlaceholder&>(*ext).set_laddr(laddr);
115116
DEBUGT("retire {}~0x{:x} as placeholder, add extent -- {}",
116117
t, paddr, length, *ext);
117118
add_extent(ext);
118119
t.add_absent_to_retired_set(ext);
120+
return ext;
119121
}
120122

121123
void Cache::dump_contents()

src/crimson/os/seastore/cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ class Cache : public ExtentTransViewRetriever {
163163
retire_extent_ret retire_extent_addr(
164164
Transaction &t, paddr_t addr, extent_len_t length);
165165

166-
void retire_absent_extent_addr(
167-
Transaction &t, paddr_t addr, extent_len_t length);
166+
CachedExtentRef retire_absent_extent_addr(
167+
Transaction &t, laddr_t laddr, paddr_t addr, extent_len_t length);
168168

169169
/**
170170
* get_root

src/crimson/os/seastore/cached_extent.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,54 +1366,6 @@ class ExtentIndex {
13661366
uint64_t bytes = 0;
13671367
};
13681368

1369-
/**
1370-
* RetiredExtentPlaceholder
1371-
*
1372-
* Cache::retire_extent_addr(Transaction&, paddr_t, extent_len_t) can retire an
1373-
* extent not currently in cache. In that case, in order to detect transaction
1374-
* invalidation, we need to add a placeholder to the cache to create the
1375-
* mapping back to the transaction. And whenever there is a transaction tries
1376-
* to read the placeholder extent out, Cache is responsible to replace the
1377-
* placeholder by the real one. Anyway, No placeholder extents should escape
1378-
* the Cache interface boundary.
1379-
*/
1380-
class RetiredExtentPlaceholder : public CachedExtent {
1381-
1382-
public:
1383-
RetiredExtentPlaceholder(extent_len_t length)
1384-
: CachedExtent(CachedExtent::retired_placeholder_construct_t{}, length) {}
1385-
1386-
CachedExtentRef duplicate_for_write(Transaction&) final {
1387-
ceph_abort_msg("Should never happen for a placeholder");
1388-
return CachedExtentRef();
1389-
}
1390-
1391-
ceph::bufferlist get_delta() final {
1392-
ceph_abort_msg("Should never happen for a placeholder");
1393-
return ceph::bufferlist();
1394-
}
1395-
1396-
static constexpr extent_types_t TYPE = extent_types_t::RETIRED_PLACEHOLDER;
1397-
extent_types_t get_type() const final {
1398-
return TYPE;
1399-
}
1400-
1401-
void apply_delta_and_adjust_crc(
1402-
paddr_t base, const ceph::bufferlist &bl) final {
1403-
ceph_abort_msg("Should never happen for a placeholder");
1404-
}
1405-
1406-
void on_rewrite(Transaction &, CachedExtent&, extent_len_t) final {}
1407-
1408-
std::ostream &print_detail(std::ostream &out) const final {
1409-
return out << ", RetiredExtentPlaceholder";
1410-
}
1411-
1412-
void on_delta_write(paddr_t record_block_offset) final {
1413-
ceph_abort_msg("Should never happen for a placeholder");
1414-
}
1415-
};
1416-
14171369
class LBAMapping;
14181370
/**
14191371
* LogicalCachedExtent

src/crimson/os/seastore/logical_child_node.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,83 @@
1010

1111
namespace crimson::os::seastore {
1212

13+
/**
14+
* RetiredExtentPlaceholder
15+
*
16+
* Cache::retire_extent_addr(Transaction&, paddr_t, extent_len_t) can retire an
17+
* extent not currently in cache. In that case, in order to detect transaction
18+
* invalidation, we need to add a placeholder to the cache to create the
19+
* mapping back to the transaction. And whenever there is a transaction tries
20+
* to read the placeholder extent out, Cache is responsible to replace the
21+
* placeholder by the real one. Anyway, No placeholder extents should escape
22+
* the Cache interface boundary.
23+
*/
24+
class RetiredExtentPlaceholder
25+
: public CachedExtent,
26+
public ChildNode<lba::LBALeafNode, RetiredExtentPlaceholder, laddr_t> {
27+
28+
public:
29+
RetiredExtentPlaceholder(extent_len_t length)
30+
: CachedExtent(CachedExtent::retired_placeholder_construct_t{}, length) {}
31+
32+
~RetiredExtentPlaceholder() {
33+
if (this->is_stable()) {
34+
lba_child_node_t::destroy();
35+
}
36+
}
37+
38+
CachedExtentRef duplicate_for_write(Transaction&) final {
39+
ceph_abort_msg("Should never happen for a placeholder");
40+
return CachedExtentRef();
41+
}
42+
43+
ceph::bufferlist get_delta() final {
44+
ceph_abort_msg("Should never happen for a placeholder");
45+
return ceph::bufferlist();
46+
}
47+
48+
static constexpr extent_types_t TYPE = extent_types_t::RETIRED_PLACEHOLDER;
49+
extent_types_t get_type() const final {
50+
return TYPE;
51+
}
52+
53+
void apply_delta_and_adjust_crc(
54+
paddr_t base, const ceph::bufferlist &bl) final {
55+
ceph_abort_msg("Should never happen for a placeholder");
56+
}
57+
58+
void on_rewrite(Transaction &, CachedExtent&, extent_len_t) final {}
59+
60+
std::ostream &print_detail(std::ostream &out) const final {
61+
return out << ", RetiredExtentPlaceholder";
62+
}
63+
64+
void on_delta_write(paddr_t record_block_offset) final {
65+
ceph_abort_msg("Should never happen for a placeholder");
66+
}
67+
68+
void set_laddr(laddr_t laddr) {
69+
this->laddr = laddr;
70+
}
71+
72+
bool is_btree_root() const {
73+
return false;
74+
}
75+
76+
laddr_t get_begin() const {
77+
assert(laddr != L_ADDR_NULL);
78+
return laddr;
79+
}
80+
81+
laddr_t get_end() const {
82+
assert(laddr != L_ADDR_NULL);
83+
return (laddr + get_length()).checked_to_laddr();
84+
}
85+
86+
private:
87+
laddr_t laddr = L_ADDR_NULL;
88+
};
89+
1390
class LogicalChildNode : public LogicalCachedExtent,
1491
public ChildNode<lba::LBALeafNode,
1592
LogicalChildNode,

src/crimson/os/seastore/retired_extent_placeholder.h

Whitespace-only changes.

0 commit comments

Comments
 (0)