Skip to content

Commit acfced0

Browse files
committed
crimson/os/seastore/transaction_manager: assert that the parents of the
mappings following which logical extents are to be retrieved are valid Signed-off-by: Xuehan Xu <[email protected]>
1 parent 2721169 commit acfced0

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ get_child_ret_t<LogicalCachedExtent>
1111
BtreeNodeMapping<key_t, val_t>::get_logical_extent(
1212
Transaction &t)
1313
{
14-
assert(parent);
15-
assert(parent->is_valid());
14+
ceph_assert(is_parent_valid());
1615
assert(pos != std::numeric_limits<uint16_t>::max());
1716
ceph_assert(t.get_trans_id() == ctx.trans.get_trans_id());
1817
auto &p = (FixedKVNode<key_t>&)*parent;
@@ -29,8 +28,7 @@ BtreeNodeMapping<key_t, val_t>::get_logical_extent(
2928
template <typename key_t, typename val_t>
3029
bool BtreeNodeMapping<key_t, val_t>::is_stable() const
3130
{
32-
assert(parent);
33-
assert(parent->is_valid());
31+
assert(is_parent_valid());
3432
assert(pos != std::numeric_limits<uint16_t>::max());
3533
auto &p = (FixedKVNode<key_t>&)*parent;
3634
return p.is_child_stable(ctx, pos);
@@ -39,8 +37,7 @@ bool BtreeNodeMapping<key_t, val_t>::is_stable() const
3937
template <typename key_t, typename val_t>
4038
bool BtreeNodeMapping<key_t, val_t>::is_data_stable() const
4139
{
42-
assert(parent);
43-
assert(parent->is_valid());
40+
assert(is_parent_valid());
4441
assert(pos != std::numeric_limits<uint16_t>::max());
4542
auto &p = (FixedKVNode<key_t>&)*parent;
4643
return p.is_child_data_stable(ctx, pos);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ class BtreeNodeMapping : public PhysicalNodeMapping<key_t, val_t> {
218218
get_child_ret_t<LogicalCachedExtent> get_logical_extent(Transaction&) final;
219219
bool is_stable() const final;
220220
bool is_data_stable() const final;
221+
bool is_parent_valid() const final {
222+
ceph_assert(parent);
223+
if (!parent->is_valid()) {
224+
return false;
225+
}
226+
return !is_unviewable_by_trans(*parent, ctx.trans);
227+
}
221228
};
222229

223230
}

src/crimson/os/seastore/cached_extent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,7 @@ class PhysicalNodeMapping {
11511151
bool is_zero_reserved() const {
11521152
return !get_val().is_real();
11531153
}
1154+
virtual bool is_parent_valid() const = 0;
11541155

11551156
virtual ~PhysicalNodeMapping() {}
11561157
protected:

src/crimson/os/seastore/transaction_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class TransactionManager : public ExtentCallbackInterface {
197197
Transaction &t,
198198
LBAMappingRef pin)
199199
{
200+
ceph_assert(pin->is_parent_valid());
200201
auto v = pin->get_logical_extent(t);
201202
if (v.has_child()) {
202203
return v.get_child_fut().safe_then([pin=std::move(pin)](auto extent) {
@@ -220,6 +221,7 @@ class TransactionManager : public ExtentCallbackInterface {
220221
LBAMappingRef pin,
221222
extent_types_t type)
222223
{
224+
ceph_assert(pin->is_parent_valid());
223225
auto v = pin->get_logical_extent(t);
224226
// checking the lba child must be atomic with creating
225227
// and linking the absent child

0 commit comments

Comments
 (0)