]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/lba_manager/btree: tolerate op_context_t without pins
authorSamuel Just <sjust@redhat.com>
Wed, 20 Oct 2021 06:48:41 +0000 (23:48 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 25 Oct 2021 08:05:18 +0000 (01:05 -0700)
Simpler to construct unit tests for the LBABTree itself without pins.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.h
src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc
src/crimson/os/seastore/lba_manager/btree/lba_btree.cc
src/crimson/os/seastore/lba_manager/btree/lba_btree_node.h

index 5803d392de1986bb864c108fe37be9e67a448760..59d032e76e1efa656e5284af695b9ccd9a71929a 100644 (file)
@@ -130,7 +130,7 @@ private:
   btree_pin_set_t pin_set;
 
   op_context_t get_context(Transaction &t) {
-    return op_context_t{cache, pin_set, t};
+    return op_context_t{cache, t, &pin_set};
   }
 
   static btree_range_pin_t &get_pin(CachedExtent &e);
index 549dabaae0dabeddd923490ceb41df1210285d97..a5416e174865e0adb605b15ee88a3817801a6475 100644 (file)
@@ -16,14 +16,15 @@ namespace crimson::os::seastore::lba_manager::btree {
 void btree_range_pin_t::take_pin(btree_range_pin_t &other)
 {
   ceph_assert(other.extent);
-  ceph_assert(other.pins);
-  other.pins->replace_pin(*this, other);
-  pins = other.pins;
-  other.pins = nullptr;
-
-  if (other.has_ref()) {
-    other.drop_ref();
-    acquire_ref();
+  if (other.pins) {
+    other.pins->replace_pin(*this, other);
+    pins = other.pins;
+    other.pins = nullptr;
+
+    if (other.has_ref()) {
+      other.drop_ref();
+      acquire_ref();
+    }
   }
 }
 
index 375b57b8172cb0d581ad545896025fa9d1db603a..31770ed688eb8c2c6b3826032add8497de4db3ce 100644 (file)
@@ -267,8 +267,10 @@ LBABtree::init_cached_extent_ret LBABtree::init_cached_extent(
          iter.get_val().paddr == logn->get_paddr()) {
        logn->set_pin(iter.get_pin());
        ceph_assert(iter.get_val().len == e->get_length());
-       c.pins.add_pin(
-         static_cast<BtreeLBAPin&>(logn->get_pin()).pin);
+       if (c.pins) {
+         c.pins->add_pin(
+           static_cast<BtreeLBAPin&>(logn->get_pin()).pin);
+       }
        DEBUGT("logical extent {} live, initialized", c.trans, *logn);
        return e;
       } else {
@@ -411,7 +413,9 @@ LBABtree::get_internal_node_ret LBABtree::get_internal_node(
     ceph_assert(depth == meta.depth);
     if (!ret->is_pending() && !ret->pin.is_linked()) {
       ret->pin.set_range(meta);
-      c.pins.add_pin(ret->pin);
+      if (c.pins) {
+       c.pins->add_pin(ret->pin);
+      }
     }
     return get_internal_node_ret(
       interruptible::ready_future_marker{},
@@ -446,7 +450,9 @@ LBABtree::get_leaf_node_ret LBABtree::get_leaf_node(
     ceph_assert(1 == meta.depth);
     if (!ret->is_pending() && !ret->pin.is_linked()) {
       ret->pin.set_range(meta);
-      c.pins.add_pin(ret->pin);
+      if (c.pins) {
+       c.pins->add_pin(ret->pin);
+      }
     }
     return get_leaf_node_ret(
       interruptible::ready_future_marker{},
index 67bc8f155a20a9b99fb9fa4eb3c65772465f9461..146942eb6f968efcbffb5454a703a7f8b3e536ab 100644 (file)
@@ -25,8 +25,8 @@ using base_iertr = LBAManager::base_iertr;
 
 struct op_context_t {
   Cache &cache;
-  btree_pin_set_t &pins;
   Transaction &trans;
+  btree_pin_set_t *pins = nullptr;
 };
 
 /**