From: Xuehan Xu Date: Sat, 25 May 2024 05:15:20 +0000 (+0800) Subject: crimson/os/seastore/transaction_manager: assert that the parents of the X-Git-Tag: v20.0.0~1647^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=acfced0c71058ea9e985de048981479d643c5afc;p=ceph.git 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 --- diff --git a/src/crimson/os/seastore/btree/btree_range_pin.cc b/src/crimson/os/seastore/btree/btree_range_pin.cc index 1e72f3da75f38..ac04705aaf067 100644 --- a/src/crimson/os/seastore/btree/btree_range_pin.cc +++ b/src/crimson/os/seastore/btree/btree_range_pin.cc @@ -11,8 +11,7 @@ get_child_ret_t BtreeNodeMapping::get_logical_extent( Transaction &t) { - assert(parent); - assert(parent->is_valid()); + ceph_assert(is_parent_valid()); assert(pos != std::numeric_limits::max()); ceph_assert(t.get_trans_id() == ctx.trans.get_trans_id()); auto &p = (FixedKVNode&)*parent; @@ -29,8 +28,7 @@ BtreeNodeMapping::get_logical_extent( template bool BtreeNodeMapping::is_stable() const { - assert(parent); - assert(parent->is_valid()); + assert(is_parent_valid()); assert(pos != std::numeric_limits::max()); auto &p = (FixedKVNode&)*parent; return p.is_child_stable(ctx, pos); @@ -39,8 +37,7 @@ bool BtreeNodeMapping::is_stable() const template bool BtreeNodeMapping::is_data_stable() const { - assert(parent); - assert(parent->is_valid()); + assert(is_parent_valid()); assert(pos != std::numeric_limits::max()); auto &p = (FixedKVNode&)*parent; return p.is_child_data_stable(ctx, pos); diff --git a/src/crimson/os/seastore/btree/btree_range_pin.h b/src/crimson/os/seastore/btree/btree_range_pin.h index 49773d98d7461..7e450f90a849e 100644 --- a/src/crimson/os/seastore/btree/btree_range_pin.h +++ b/src/crimson/os/seastore/btree/btree_range_pin.h @@ -218,6 +218,13 @@ public: get_child_ret_t get_logical_extent(Transaction&) final; bool is_stable() const final; bool is_data_stable() const final; + bool is_parent_valid() const final { + ceph_assert(parent); + if (!parent->is_valid()) { + return false; + } + return !is_unviewable_by_trans(*parent, ctx.trans); + } }; } diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index c81304668fb38..5c68207e80ca6 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -1151,6 +1151,7 @@ public: bool is_zero_reserved() const { return !get_val().is_real(); } + virtual bool is_parent_valid() const = 0; virtual ~PhysicalNodeMapping() {} protected: diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index c0aa518a6790a..177996c8bd8a8 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -197,6 +197,7 @@ public: Transaction &t, LBAMappingRef pin) { + ceph_assert(pin->is_parent_valid()); auto v = pin->get_logical_extent(t); if (v.has_child()) { return v.get_child_fut().safe_then([pin=std::move(pin)](auto extent) { @@ -220,6 +221,7 @@ public: LBAMappingRef pin, extent_types_t type) { + ceph_assert(pin->is_parent_valid()); auto v = pin->get_logical_extent(t); // checking the lba child must be atomic with creating // and linking the absent child