]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/transaction_manager: assert that the parents of the
authorXuehan Xu <xxhdx1985126@gmail.com>
Sat, 25 May 2024 05:15:20 +0000 (13:15 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 25 Jul 2024 07:39:22 +0000 (10:39 +0300)
mappings following which logical extents are to be retrieved are valid

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
(cherry picked from commit acfced0c71058ea9e985de048981479d643c5afc)

src/crimson/os/seastore/btree/btree_range_pin.cc
src/crimson/os/seastore/btree/btree_range_pin.h
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/transaction_manager.h

index 1e72f3da75f386f421d76a4aa6db582766d3831d..ac04705aaf0672398f95fd9ba7ac904fd677a9ab 100644 (file)
@@ -11,8 +11,7 @@ get_child_ret_t<LogicalCachedExtent>
 BtreeNodeMapping<key_t, val_t>::get_logical_extent(
   Transaction &t)
 {
-  assert(parent);
-  assert(parent->is_valid());
+  ceph_assert(is_parent_valid());
   assert(pos != std::numeric_limits<uint16_t>::max());
   ceph_assert(t.get_trans_id() == ctx.trans.get_trans_id());
   auto &p = (FixedKVNode<key_t>&)*parent;
@@ -29,8 +28,7 @@ BtreeNodeMapping<key_t, val_t>::get_logical_extent(
 template <typename key_t, typename val_t>
 bool BtreeNodeMapping<key_t, val_t>::is_stable() const
 {
-  assert(parent);
-  assert(parent->is_valid());
+  assert(is_parent_valid());
   assert(pos != std::numeric_limits<uint16_t>::max());
   auto &p = (FixedKVNode<key_t>&)*parent;
   return p.is_child_stable(ctx, pos);
@@ -39,8 +37,7 @@ bool BtreeNodeMapping<key_t, val_t>::is_stable() const
 template <typename key_t, typename val_t>
 bool BtreeNodeMapping<key_t, val_t>::is_data_stable() const
 {
-  assert(parent);
-  assert(parent->is_valid());
+  assert(is_parent_valid());
   assert(pos != std::numeric_limits<uint16_t>::max());
   auto &p = (FixedKVNode<key_t>&)*parent;
   return p.is_child_data_stable(ctx, pos);
index 49773d98d7461d542f821b525e66f3f479f4aac0..7e450f90a849e4eb317cacbfdbd85179e5beca01 100644 (file)
@@ -218,6 +218,13 @@ public:
   get_child_ret_t<LogicalCachedExtent> 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);
+  }
 };
 
 }
index c81304668fb3843af0d2459307c08c5c017fef1b..5c68207e80ca69e9565b80bb39a828b923e88e9b 100644 (file)
@@ -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:
index cc3abe42d9d74ecc0cf211e71fee585cd878ebc1..f6bbc8aa4152b106258d4989af380db704b15beb 100644 (file)
@@ -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