Skip to content

Commit c0cd12c

Browse files
zhscnMatan-B
authored andcommitted
crimson/os/seastore: remove PhysicalNodeMapping and BtreeNodeMapping
Signed-off-by: Zhang Song <[email protected]> (cherry picked from commit 3c4d047)
1 parent b918248 commit c0cd12c

File tree

5 files changed

+101
-134
lines changed

5 files changed

+101
-134
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace crimson::os::seastore::backref {
1111

1212
class BtreeBackrefMapping : public BackrefMapping {
1313
public:
14-
BtreeBackrefMapping(op_context_t ctx)
15-
: BackrefMapping(ctx) {}
1614
BtreeBackrefMapping(
1715
op_context_t ctx,
1816
BackrefLeafNodeRef parent,

src/crimson/os/seastore/backref_mapping.h

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,45 @@
77

88
namespace crimson::os::seastore {
99

10-
class BackrefMapping : public BtreeNodeMapping<paddr_t, laddr_t> {
10+
class BackrefMapping {
11+
op_context_t ctx;
12+
CachedExtentRef parent;
13+
fixed_kv_node_meta_t<paddr_t> range;
14+
laddr_t value;
15+
extent_len_t len = 0;
16+
uint16_t pos = std::numeric_limits<uint16_t>::max();
1117
extent_types_t type;
1218
public:
13-
BackrefMapping(op_context_t ctx)
14-
: BtreeNodeMapping(ctx) {}
15-
template <typename... T>
16-
BackrefMapping(extent_types_t type, T&&... t)
17-
: BtreeNodeMapping(std::forward<T>(t)...),
18-
type(type) {}
19+
BackrefMapping(
20+
extent_types_t type,
21+
op_context_t ctx,
22+
CachedExtentRef parent,
23+
uint16_t pos,
24+
laddr_t value,
25+
extent_len_t len,
26+
fixed_kv_node_meta_t<paddr_t> meta)
27+
: ctx(ctx),
28+
parent(parent),
29+
range(meta),
30+
value(value),
31+
len(len),
32+
pos(pos),
33+
type(type)
34+
{}
35+
36+
extent_len_t get_length() const {
37+
ceph_assert(range.end > range.begin);
38+
return len;
39+
}
40+
41+
laddr_t get_val() const {
42+
return value;
43+
}
44+
45+
paddr_t get_key() const {
46+
return range.begin;
47+
}
48+
1949
extent_types_t get_type() const {
2050
return type;
2151
}

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

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -100,87 +100,4 @@ struct __attribute__((packed)) fixed_kv_node_meta_le_t {
100100
}
101101
};
102102

103-
template <typename key_t, typename val_t>
104-
class BtreeNodeMapping : public PhysicalNodeMapping<key_t, val_t> {
105-
protected:
106-
op_context_t ctx;
107-
/**
108-
* parent
109-
*
110-
* populated until link_extent is called to ensure cache residence
111-
* until add_pin is called.
112-
*/
113-
CachedExtentRef parent;
114-
115-
pladdr_t value;
116-
extent_len_t len = 0;
117-
fixed_kv_node_meta_t<key_t> range;
118-
uint16_t pos = std::numeric_limits<uint16_t>::max();
119-
fixed_kv_node_meta_t<key_t> _get_pin_range() const {
120-
return range;
121-
}
122-
123-
public:
124-
using val_type = val_t;
125-
BtreeNodeMapping(op_context_t ctx) : ctx(ctx) {}
126-
127-
BtreeNodeMapping(
128-
op_context_t ctx,
129-
CachedExtentRef parent,
130-
uint16_t pos,
131-
pladdr_t value,
132-
extent_len_t len,
133-
fixed_kv_node_meta_t<key_t> meta)
134-
: ctx(ctx),
135-
parent(parent),
136-
value(value),
137-
len(len),
138-
range(meta),
139-
pos(pos)
140-
{}
141-
142-
CachedExtentRef get_parent() const final {
143-
return parent;
144-
}
145-
146-
CachedExtentRef get_parent() {
147-
return parent;
148-
}
149-
150-
uint16_t get_pos() const final {
151-
return pos;
152-
}
153-
154-
extent_len_t get_length() const final {
155-
ceph_assert(range.end > range.begin);
156-
return len;
157-
}
158-
159-
val_t get_val() const final {
160-
if constexpr (std::is_same_v<val_t, paddr_t>) {
161-
return value.get_paddr();
162-
} else {
163-
static_assert(std::is_same_v<val_t, laddr_t>);
164-
return value.get_laddr();
165-
}
166-
}
167-
168-
key_t get_key() const override {
169-
return range.begin;
170-
}
171-
172-
bool has_been_invalidated() const final {
173-
return parent->has_been_invalidated();
174-
}
175-
176-
bool is_parent_viewable() const final {
177-
ceph_assert(parent);
178-
return parent->is_viewable_by_trans(ctx.trans).first;
179-
}
180-
bool is_parent_valid() const final {
181-
ceph_assert(parent);
182-
return parent->is_valid();
183-
}
184-
};
185-
186103
}

src/crimson/os/seastore/cached_extent.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,7 @@ class CachedExtent
11101110
friend class crimson::os::seastore::SegmentedAllocator;
11111111
friend class crimson::os::seastore::TransactionManager;
11121112
friend class crimson::os::seastore::ExtentPlacementManager;
1113-
template <typename, typename>
1114-
friend class BtreeNodeMapping;
1113+
friend class LBAMapping;
11151114
friend class ::btree_lba_manager_test;
11161115
friend class ::lba_btree_test;
11171116
friend class ::btree_test_base;
@@ -1313,41 +1312,6 @@ class ExtentIndex {
13131312
uint64_t bytes = 0;
13141313
};
13151314

1316-
template <typename key_t, typename>
1317-
class PhysicalNodeMapping;
1318-
1319-
template <typename key_t, typename val_t>
1320-
using PhysicalNodeMappingRef = std::unique_ptr<PhysicalNodeMapping<key_t, val_t>>;
1321-
1322-
template <typename key_t, typename val_t>
1323-
class PhysicalNodeMapping {
1324-
public:
1325-
PhysicalNodeMapping() = default;
1326-
PhysicalNodeMapping(const PhysicalNodeMapping&) = delete;
1327-
virtual extent_len_t get_length() const = 0;
1328-
virtual val_t get_val() const = 0;
1329-
virtual key_t get_key() const = 0;
1330-
virtual bool has_been_invalidated() const = 0;
1331-
virtual CachedExtentRef get_parent() const = 0;
1332-
virtual uint16_t get_pos() const = 0;
1333-
virtual uint32_t get_checksum() const {
1334-
ceph_abort("impossible");
1335-
return 0;
1336-
}
1337-
virtual bool is_parent_viewable() const = 0;
1338-
virtual bool is_parent_valid() const = 0;
1339-
virtual bool parent_modified() const {
1340-
ceph_abort("impossible");
1341-
return false;
1342-
};
1343-
1344-
virtual void maybe_fix_pos() {
1345-
ceph_abort("impossible");
1346-
}
1347-
1348-
virtual ~PhysicalNodeMapping() {}
1349-
};
1350-
13511315
/**
13521316
* RetiredExtentPlaceholder
13531317
*

src/crimson/os/seastore/lba_mapping.h

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,64 @@ using LBAMappingRef = std::unique_ptr<LBAMapping>;
1515

1616
class LogicalCachedExtent;
1717

18-
class LBAMapping : public BtreeNodeMapping<laddr_t, paddr_t> {
18+
class LBAMapping {
1919
public:
2020
LBAMapping(op_context_t ctx)
21-
: BtreeNodeMapping<laddr_t, paddr_t>(ctx) {}
22-
template <typename... T>
23-
LBAMapping(T&&... t)
24-
: BtreeNodeMapping<laddr_t, paddr_t>(std::forward<T>(t)...)
21+
: ctx(ctx) {}
22+
LBAMapping(
23+
op_context_t ctx,
24+
CachedExtentRef parent,
25+
uint16_t pos,
26+
pladdr_t value,
27+
extent_len_t len,
28+
fixed_kv_node_meta_t<laddr_t> meta)
29+
: ctx(ctx),
30+
parent(parent),
31+
value(value),
32+
len(len),
33+
range(meta),
34+
pos(pos)
2535
{}
2636

37+
CachedExtentRef get_parent() {
38+
return parent;
39+
}
40+
41+
uint16_t get_pos() const {
42+
return pos;
43+
}
44+
45+
extent_len_t get_length() const {
46+
ceph_assert(range.end > range.begin);
47+
return len;
48+
}
49+
50+
paddr_t get_val() const {
51+
return value.get_paddr();
52+
}
53+
54+
virtual laddr_t get_key() const {
55+
return range.begin;
56+
}
57+
58+
bool has_been_invalidated() const {
59+
return parent->has_been_invalidated();
60+
}
61+
62+
bool is_parent_viewable() const {
63+
ceph_assert(parent);
64+
return parent->is_viewable_by_trans(ctx.trans).first;
65+
}
66+
67+
bool is_parent_valid() const {
68+
ceph_assert(parent);
69+
return parent->is_valid();
70+
}
71+
72+
virtual void maybe_fix_pos() = 0;
73+
virtual bool parent_modified() const = 0;
74+
virtual uint32_t get_checksum() const = 0;
75+
2776
// An lba pin may be indirect, see comments in lba_manager/btree/btree_lba_manager.h
2877
virtual bool is_indirect() const = 0;
2978
virtual laddr_t get_intermediate_key() const = 0;
@@ -55,6 +104,15 @@ class LBAMapping : public BtreeNodeMapping<laddr_t, paddr_t> {
55104
virtual ~LBAMapping() {}
56105
protected:
57106
virtual LBAMappingRef _duplicate(op_context_t) const = 0;
107+
108+
op_context_t ctx;
109+
CachedExtentRef parent;
110+
111+
pladdr_t value;
112+
extent_len_t len = 0;
113+
fixed_kv_node_meta_t<laddr_t> range;
114+
uint16_t pos = std::numeric_limits<uint16_t>::max();
115+
58116
std::optional<child_pos_t<
59117
lba_manager::btree::LBALeafNode>> child_pos = std::nullopt;
60118
};

0 commit comments

Comments
 (0)