Skip to content

Commit 6692edf

Browse files
committed
crimson/os/seastore/btree: allow fixed-kv-btree to query Cache when
getting child nodes during the booting Signed-off-by: Xuehan Xu <[email protected]>
1 parent 415059c commit 6692edf

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/crimson/os/seastore/btree/fixed_kv_btree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ class FixedKVBtree {
14371437
}
14381438
}
14391439
};
1440-
return c.cache.template get_absent_extent<internal_node_t>(
1440+
return c.cache.template maybe_get_absent_extent<internal_node_t>(
14411441
c.trans,
14421442
offset,
14431443
node_size,
@@ -1521,7 +1521,7 @@ class FixedKVBtree {
15211521
}
15221522
}
15231523
};
1524-
return c.cache.template get_absent_extent<leaf_node_t>(
1524+
return c.cache.template maybe_get_absent_extent<leaf_node_t>(
15251525
c.trans,
15261526
offset,
15271527
node_size,

src/crimson/os/seastore/cache.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ class Cache : public ExtentTransViewRetriever,
411411

412412
SUBTRACET(seastore_cache, "{} {}~0x{:x} is absent on t, query cache ...",
413413
t, T::TYPE, offset, length);
414+
ceph_assert(!booting);
414415
const auto t_src = t.get_src();
415416

416417
// partial read
@@ -468,6 +469,49 @@ class Cache : public ExtentTransViewRetriever,
468469
std::forward<Func>(extent_init_func));
469470
}
470471

472+
template <typename T, typename Func>
473+
get_extent_iertr::future<TCachedExtentRef<T>> maybe_get_absent_extent(
474+
Transaction &t,
475+
paddr_t offset,
476+
extent_len_t length,
477+
Func &&extent_init_func) {
478+
LOG_PREFIX(Cache::maybe_get_absent_extent);
479+
if (unlikely(booting)) {
480+
#ifndef NDEBUG
481+
CachedExtentRef ret;
482+
auto r = t.get_extent(offset, &ret);
483+
if (r != Transaction::get_extent_ret::ABSENT) {
484+
SUBERRORT(seastore_cache, "unexpected non-absent extent {}", t, *ret);
485+
ceph_abort();
486+
}
487+
#endif
488+
489+
SUBTRACET(seastore_cache, "{} {}~0x{:x} is absent on t, query cache ...",
490+
t, T::TYPE, offset, length);
491+
const auto t_src = t.get_src();
492+
auto f = [&t, this, t_src](CachedExtent &ext) {
493+
// XXX: is_stable_dirty() may not be linked in lba tree
494+
assert(ext.is_stable());
495+
assert(T::TYPE == ext.get_type());
496+
cache_access_stats_t& access_stats = get_by_ext(
497+
get_by_src(stats.access_by_src_ext, t_src),
498+
T::TYPE);
499+
++access_stats.load_absent;
500+
++stats.access.load_absent;
501+
502+
t.add_to_read_set(CachedExtentRef(&ext));
503+
touch_extent_fully(ext, &t_src, t.get_cache_hint());
504+
};
505+
return trans_intr::make_interruptible(
506+
do_get_caching_extent<T>(
507+
offset, length, 0, length,
508+
std::forward<Func>(extent_init_func), std::move(f), &t_src)
509+
);
510+
}
511+
return get_absent_extent<T>(t, offset, length, 0, length,
512+
std::forward<Func>(extent_init_func));
513+
}
514+
471515
CachedExtentRef peek_extent_viewable_by_trans(
472516
Transaction &t,
473517
CachedExtentRef extent) final
@@ -1557,6 +1601,9 @@ class Cache : public ExtentTransViewRetriever,
15571601
return stats.omap_tree_depth;
15581602
}
15591603

1604+
void boot_done() {
1605+
booting = false;
1606+
}
15601607
private:
15611608
void touch_extent_fully(
15621609
CachedExtent &ext,
@@ -1943,6 +1990,8 @@ class Cache : public ExtentTransViewRetriever,
19431990
return CachedExtentRef();
19441991
}
19451992
}
1993+
1994+
bool booting = true;
19461995
};
19471996
using CacheRef = std::unique_ptr<Cache>;
19481997

src/crimson/os/seastore/transaction_manager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ TransactionManager::mount()
174174
return epm->open_for_write();
175175
}).safe_then([FNAME, this] {
176176
epm->start_background();
177+
cache->boot_done();
177178
INFO("done");
178179
}).handle_error(
179180
mount_ertr::pass_further{},

0 commit comments

Comments
 (0)