SUBDEBUGT(seastore_cache, "reset", t);
}
- /**
- * drop_from_cache
- *
- * Drop extent from cache. Intended for use when
- * ref refers to a logically dead extent as during
- * replay.
- */
- void drop_from_cache(CachedExtentRef ref) {
- remove_extent(ref);
- }
-
/// Declare ref retired in t
void retire_extent(Transaction &t, CachedExtentRef ref) {
t.add_to_retired_set(ref);
return seastar::do_with(
std::forward<F>(f),
std::move(dirty),
- [&t](auto &f, auto &refs) mutable {
- return trans_intr::do_for_each(
- refs,
- [&t, &f](auto &e) { return f(t, e); });
- }).handle_error_interruptible(
- init_cached_extents_iertr::pass_further{},
- crimson::ct_error::assert_all{
- "Invalid error in Cache::init_cached_extents"
- }
- );
+ [this, &t](auto &f, auto &refs) mutable
+ {
+ return trans_intr::do_for_each(
+ refs,
+ [this, &t, &f](auto &e)
+ {
+ return f(t, e
+ ).si_then([this, &t, e](bool is_alive) {
+ if (!is_alive) {
+ remove_extent(e);
+ }
+ });
+ });
+ }).handle_error_interruptible(
+ init_cached_extents_iertr::pass_further{},
+ crimson::ct_error::assert_all{
+ "Invalid error in Cache::init_cached_extents"
+ }
+ );
}
/**
* Implementation must initialize the LBAPin on any
* LogicalCachedExtent's and may also read in any dependent
* structures, etc.
+ *
+ * @return returns whether the extent is alive
*/
using init_cached_extent_iertr = base_iertr;
- using init_cached_extent_ret = init_cached_extent_iertr::future<>;
+ using init_cached_extent_ret = init_cached_extent_iertr::future<bool>;
virtual init_cached_extent_ret init_cached_extent(
Transaction &t,
CachedExtentRef e) = 0;
{
LOG_PREFIX(BtreeLBAManager::init_cached_extent);
DEBUGT("extent {}", t, *e);
- auto c = get_context(t);
- return with_btree(
- c,
- [c, e](auto &btree) {
- return btree.init_cached_extent(
- c, e
- ).si_then([](auto) {});
+ return seastar::do_with(bool(), [this, e, &t](bool& ret) {
+ auto c = get_context(t);
+ return with_btree(c, [c, e, &ret](auto &btree) {
+ return btree.init_cached_extent(c, e
+ ).si_then([&ret](bool is_alive) {
+ ret = is_alive;
+ });
+ }).si_then([&ret] {
+ return ret;
});
+ });
}
BtreeLBAManager::scan_mappings_ret BtreeLBAManager::scan_mappings(
c.pins->add_pin(
static_cast<BtreeLBAPin&>(logn->get_pin()).pin);
}
- DEBUGT("logical extent {} live, initialized", c.trans, *logn);
- return e;
+ DEBUGT("logical extent {} live", c.trans, *logn);
+ return true;
} else {
- DEBUGT("logical extent {} not live, dropping", c.trans, *logn);
- c.cache.drop_from_cache(logn);
- return CachedExtentRef();
+ DEBUGT("logical extent {} not live", c.trans, *logn);
+ return false;
}
});
} else if (e->get_type() == extent_types_t::LADDR_INTERNAL) {
if (cand_depth <= iter.get_depth() &&
&*iter.get_internal(cand_depth).node == &*eint) {
DEBUGT("extent {} is live", c.trans, *eint);
- return e;
+ return true;
} else {
DEBUGT("extent {} is not live", c.trans, *eint);
- c.cache.drop_from_cache(eint);
- return CachedExtentRef();
+ return false;
}
});
} else if (e->get_type() == extent_types_t::LADDR_LEAF) {
// Note, this check is valid even if iter.is_end()
if (iter.leaf.node == &*eleaf) {
DEBUGT("extent {} is live", c.trans, *eleaf);
- return e;
+ return true;
} else {
DEBUGT("extent {} is not live", c.trans, *eleaf);
- c.cache.drop_from_cache(eleaf);
- return CachedExtentRef();
+ return false;
}
});
} else {
e->get_type());
return init_cached_extent_ret(
interruptible::ready_future_marker{},
- e);
+ true);
}
}
* Checks whether e is live (reachable from lba tree) and drops or initializes
* accordingly.
*
- * Returns e if live and a null CachedExtentRef otherwise.
+ * Returns if e is live.
*/
using init_cached_extent_iertr = base_iertr;
- using init_cached_extent_ret = init_cached_extent_iertr::future<CachedExtentRef>;
+ using init_cached_extent_ret = init_cached_extent_iertr::future<bool>;
init_cached_extent_ret init_cached_extent(op_context_t c, CachedExtentRef e);
/// get_leaf_if_live: get leaf node at laddr/addr if still live