crimson/.../lba_manager/btree: hold a reference to parent until added to cache

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>
This commit is contained in:
Samuel Just 2020-08-26 14:49:34 -07:00
parent bed1b7bb30
commit c82610c070
3 changed files with 16 additions and 2 deletions

View 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:

View 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));
}

View 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}));
}