Skip to content

Commit 6933f4c

Browse files
committed
crimson/os/seastore/cache: verify pending extents in get_extent_viewable_by_trans()
Distinguish specific cases carefully. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent a81d36c commit 6933f4c

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

src/crimson/os/seastore/cache.h

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,45 @@ class Cache {
476476
CachedExtentRef extent)
477477
{
478478
assert(extent->is_valid());
479-
auto p_extent = extent->get_transactional_view(t);
480-
if (!p_extent->is_pending_in_trans(t.get_trans_id())) {
481-
t.add_to_read_set(p_extent);
482-
touch_extent(*p_extent);
479+
CachedExtent* p_extent;
480+
if (extent->is_stable()) {
481+
p_extent = extent->get_transactional_view(t);
482+
if (p_extent != extent.get()) {
483+
assert(!extent->is_stable_writting());
484+
assert(p_extent->is_pending_in_trans(t.get_trans_id()));
485+
assert(!p_extent->is_stable_writting());
486+
if (p_extent->is_mutable()) {
487+
assert(p_extent->is_fully_loaded());
488+
assert(!p_extent->is_pending_io());
489+
return get_extent_ertr::make_ready_future<CachedExtentRef>(
490+
CachedExtentRef(p_extent));
491+
} else {
492+
assert(p_extent->is_exist_clean());
493+
}
494+
} else {
495+
// stable from trans-view
496+
assert(!p_extent->is_pending_in_trans(t.get_trans_id()));
497+
t.add_to_read_set(p_extent);
498+
touch_extent(*p_extent);
499+
}
500+
} else {
501+
assert(!extent->is_stable_writting());
502+
assert(extent->is_pending_in_trans(t.get_trans_id()));
503+
if (extent->is_mutable()) {
504+
assert(extent->is_fully_loaded());
505+
assert(!extent->is_pending_io());
506+
return get_extent_ertr::make_ready_future<CachedExtentRef>(extent);
507+
} else {
508+
assert(extent->is_exist_clean());
509+
p_extent = extent.get();
510+
}
483511
}
512+
513+
assert(p_extent->is_stable() || p_extent->is_exist_clean());
484514
// user should not see RETIRED_PLACEHOLDER extents
485515
ceph_assert(p_extent->get_type() != extent_types_t::RETIRED_PLACEHOLDER);
486516
if (!p_extent->is_fully_loaded()) {
487517
assert(!p_extent->is_mutable());
488-
touch_extent(*p_extent);
489518
LOG_PREFIX(Cache::get_extent_viewable_by_trans);
490519
SUBDEBUG(seastore_cache,
491520
"{} {}~{} is present without been fully loaded, reading ... -- {}",

0 commit comments

Comments
 (0)