]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/.../lba_manager/btree: hold a reference to parent until added to cache
authorSamuel Just <sjust@redhat.com>
Wed, 26 Aug 2020 21:49:34 +0000 (14:49 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 19 Oct 2020 22:18:14 +0000 (15:18 -0700)
Currently, we need to rely on the Transaction::read_set to ensure cache
residence of a leaf node until TransactionManager adds the logical
extent to the cache.  The next patch, however, will introduce a lazy
flag for Transaction's to enable doing snapshot inconsistent scans
without populating the read_set, so we'll want this to work without
it.

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.h
src/crimson/os/seastore/lba_manager/btree/lba_btree_node_impl.cc

index 8287cfac2797e44614d5c421de6ba27ef46bcc12..7de463026bcb37d6359da4128d289ba13da5684d 100644 (file)
@@ -102,7 +102,9 @@ public:
     CachedExtentRef extent);
 
   void add_pin(LBAPin &pin) final {
-    pin_set.add_pin(reinterpret_cast<BtreeLBAPin*>(&pin)->pin);
+    auto *bpin = reinterpret_cast<BtreeLBAPin*>(&pin);
+    pin_set.add_pin(bpin->pin);
+    bpin->parent = nullptr;
   }
 
 private:
index 3f6b5f12f62daf0be4e7fb1f72b0d245e39e5197..3fa218fc8cdc7f19fa23961582ac3ea9797aa3ef 100644 (file)
@@ -219,6 +219,15 @@ public:
 
 class BtreeLBAPin : public LBAPin {
   friend class BtreeLBAManager;
+
+  /**
+   * parent
+   *
+   * populated until link_extent is called to ensure cache residence
+   * until add_pin is called.
+   */
+  CachedExtentRef parent;
+
   paddr_t paddr;
   btree_range_pin_t pin;
 
@@ -226,9 +235,10 @@ public:
   BtreeLBAPin() = default;
 
   BtreeLBAPin(
+    CachedExtentRef parent,
     paddr_t paddr,
     lba_node_meta_t &&meta)
-    : paddr(paddr) {
+    : parent(parent), paddr(paddr) {
     pin.set_range(std::move(meta));
   }
 
index 4738ae6849ab34c17c932e8ac1f069aaec72dc1d..1676a82be077f2c422647830443b309224b4ed11 100644 (file)
@@ -435,6 +435,7 @@ LBALeafNode::lookup_range_ret LBALeafNode::lookup_range(
     auto begin = i->get_key();
     ret.emplace_back(
       std::make_unique<BtreeLBAPin>(
+       this,
        val.paddr,
        lba_node_meta_t{ begin, begin + val.len, 0}));
   }
@@ -473,6 +474,7 @@ LBALeafNode::insert_ret LBALeafNode::insert(
   return insert_ret(
     insert_ertr::ready_future_marker{},
     std::make_unique<BtreeLBAPin>(
+      this,
       val.paddr,
       lba_node_meta_t{ begin, begin + val.len, 0}));
 }