Skip to content

Commit f6d0bcb

Browse files
committed
crimson/os/seastore/cache: do seperated add_to_read_set steps for
initial pending and stable writing extents Fixes: https://tracker.ceph.com/issues/70976 Signed-off-by: Xuehan Xu <[email protected]> Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 4328521 commit f6d0bcb

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/crimson/os/seastore/cache.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,19 @@ class Cache : public ExtentTransViewRetriever {
471471

472472
const auto t_src = t.get_src();
473473
auto ext_type = extent->get_type();
474+
// FIXME: retired-placeholder isn't linked in the lba tree yet.
475+
// We think it's still working because:
476+
// 1. A retired-placeholder must be an ObjectDataBlock
477+
// 2. Per rados object, no read is possible during write,
478+
// and write cannot be parallel
479+
assert(!is_retired_placeholder_type(ext_type));
474480
cache_access_stats_t& access_stats = get_by_ext(
475481
get_by_src(stats.access_by_src_ext, t_src),
476482
ext_type);
477483

478484
CachedExtent* p_extent;
485+
bool needs_step_2 = false;
486+
bool needs_touch = false;
479487
if (extent->is_stable()) {
480488
p_extent = extent->get_transactional_view(t);
481489
if (p_extent != extent.get()) {
@@ -495,16 +503,22 @@ class Cache : public ExtentTransViewRetriever {
495503
} else {
496504
// stable from trans-view
497505
assert(!p_extent->is_pending_in_trans(t.get_trans_id()));
498-
if (t.maybe_add_to_read_set(p_extent)) {
506+
auto ret = t.maybe_add_to_read_set(p_extent);
507+
if (ret.added) {
499508
if (p_extent->is_dirty()) {
500509
++access_stats.cache_dirty;
501510
++stats.access.cache_dirty;
502511
} else {
503512
++access_stats.cache_lru;
504513
++stats.access.cache_lru;
505514
}
506-
touch_extent(*p_extent, &t_src, t.get_cache_hint());
515+
if (ret.is_paddr_known) {
516+
touch_extent(*p_extent, &t_src, t.get_cache_hint());
517+
} else {
518+
needs_touch = true;
519+
}
507520
} else {
521+
// already exists
508522
if (p_extent->is_dirty()) {
509523
++access_stats.trans_dirty;
510524
++stats.access.trans_dirty;
@@ -513,6 +527,9 @@ class Cache : public ExtentTransViewRetriever {
513527
++stats.access.trans_lru;
514528
}
515529
}
530+
// step 2 maybe reordered after wait_io(),
531+
// always try step 2 if paddr unknown
532+
needs_step_2 = !ret.is_paddr_known;
516533
}
517534
} else {
518535
assert(!extent->is_stable_writting());
@@ -538,7 +555,13 @@ class Cache : public ExtentTransViewRetriever {
538555

539556
return trans_intr::make_interruptible(
540557
p_extent->wait_io()
541-
).then_interruptible([p_extent] {
558+
).then_interruptible([p_extent, needs_touch, needs_step_2, &t, this, &t_src] {
559+
if (needs_step_2) {
560+
t.maybe_add_to_read_set_step_2(p_extent);
561+
}
562+
if (needs_touch) {
563+
touch_extent(*p_extent, &t_src, t.get_cache_hint());
564+
}
542565
return get_extent_iertr::make_ready_future<CachedExtentRef>(
543566
CachedExtentRef(p_extent));
544567
});

0 commit comments

Comments
 (0)