Skip to content

Commit 365d689

Browse files
authored
Merge pull request ceph#58467 from cyx1231st/wip-seastore-track-outstanding
crimson/os/seastore: track transactions/conflicts/outstanding periodically Reviewed-by: Myoungwon Oh <[email protected]> Reviewed-by: Samuel Just <[email protected]>
2 parents f910e9d + 736512a commit 365d689

File tree

11 files changed

+466
-51
lines changed

11 files changed

+466
-51
lines changed

src/crimson/os/seastore/async_cleaner.cc

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,14 @@ JournalTrimmerImpl::trim_alloc()
598598
{
599599
LOG_PREFIX(JournalTrimmerImpl::trim_alloc);
600600
assert(background_callback->is_ready());
601-
return repeat_eagain([this, FNAME] {
601+
602+
auto& shard_stats = extent_callback->get_shard_stats();
603+
++(shard_stats.trim_alloc_num);
604+
++(shard_stats.pending_bg_num);
605+
606+
return repeat_eagain([this, FNAME, &shard_stats] {
607+
++(shard_stats.repeat_trim_alloc_num);
608+
602609
return extent_callback->with_transaction_intr(
603610
Transaction::src_t::TRIM_ALLOC,
604611
"trim_alloc",
@@ -622,8 +629,11 @@ JournalTrimmerImpl::trim_alloc()
622629
return seastar::now();
623630
});
624631
});
625-
}).safe_then([this, FNAME] {
632+
}).finally([this, FNAME, &shard_stats] {
626633
DEBUG("finish, alloc_tail={}", journal_alloc_tail);
634+
635+
assert(shard_stats.pending_bg_num);
636+
--(shard_stats.pending_bg_num);
627637
});
628638
}
629639

@@ -632,7 +642,14 @@ JournalTrimmerImpl::trim_dirty()
632642
{
633643
LOG_PREFIX(JournalTrimmerImpl::trim_dirty);
634644
assert(background_callback->is_ready());
635-
return repeat_eagain([this, FNAME] {
645+
646+
auto& shard_stats = extent_callback->get_shard_stats();
647+
++(shard_stats.trim_dirty_num);
648+
++(shard_stats.pending_bg_num);
649+
650+
return repeat_eagain([this, FNAME, &shard_stats] {
651+
++(shard_stats.repeat_trim_dirty_num);
652+
636653
return extent_callback->with_transaction_intr(
637654
Transaction::src_t::TRIM_DIRTY,
638655
"trim_dirty",
@@ -662,8 +679,11 @@ JournalTrimmerImpl::trim_dirty()
662679
return extent_callback->submit_transaction_direct(t);
663680
});
664681
});
665-
}).safe_then([this, FNAME] {
682+
}).finally([this, FNAME, &shard_stats] {
666683
DEBUG("finish, dirty_tail={}", journal_dirty_tail);
684+
685+
assert(shard_stats.pending_bg_num);
686+
--(shard_stats.pending_bg_num);
667687
});
668688
}
669689

@@ -1073,6 +1093,14 @@ SegmentCleaner::do_reclaim_space(
10731093
std::size_t &reclaimed,
10741094
std::size_t &runs)
10751095
{
1096+
auto& shard_stats = extent_callback->get_shard_stats();
1097+
if (is_cold) {
1098+
++(shard_stats.cleaner_cold_num);
1099+
} else {
1100+
++(shard_stats.cleaner_main_num);
1101+
}
1102+
++(shard_stats.pending_bg_num);
1103+
10761104
// Extents satisfying any of the following requirements
10771105
// are considered DEAD:
10781106
// 1. can't find the corresponding mapping in both the
@@ -1082,13 +1110,17 @@ SegmentCleaner::do_reclaim_space(
10821110
// tree doesn't match the extent's paddr
10831111
// 3. the extent is physical and doesn't exist in the
10841112
// lba tree, backref tree or backref cache;
1085-
return repeat_eagain([this, &backref_extents,
1113+
return repeat_eagain([this, &backref_extents, &shard_stats,
10861114
&pin_list, &reclaimed, &runs] {
10871115
reclaimed = 0;
10881116
runs++;
1089-
auto src = Transaction::src_t::CLEANER_MAIN;
1117+
transaction_type_t src;
10901118
if (is_cold) {
10911119
src = Transaction::src_t::CLEANER_COLD;
1120+
++(shard_stats.repeat_cleaner_cold_num);
1121+
} else {
1122+
src = Transaction::src_t::CLEANER_MAIN;
1123+
++(shard_stats.repeat_cleaner_main_num);
10921124
}
10931125
return extent_callback->with_transaction_intr(
10941126
src,
@@ -1167,6 +1199,9 @@ SegmentCleaner::do_reclaim_space(
11671199
return extent_callback->submit_transaction_direct(t);
11681200
});
11691201
});
1202+
}).finally([&shard_stats] {
1203+
assert(shard_stats.pending_bg_num);
1204+
--(shard_stats.pending_bg_num);
11701205
});
11711206
}
11721207

@@ -1202,6 +1237,7 @@ SegmentCleaner::clean_space_ret SegmentCleaner::clean_space()
12021237
std::pair<std::vector<CachedExtentRef>, backref_pin_list_t>(),
12031238
[this](auto &weak_read_ret) {
12041239
return repeat_eagain([this, &weak_read_ret] {
1240+
// Note: not tracked by shard_stats_t intentionally.
12051241
return extent_callback->with_transaction_intr(
12061242
Transaction::src_t::READ,
12071243
"retrieve_from_backref_tree",

src/crimson/os/seastore/async_cleaner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ class ExtentCallbackInterface {
277277

278278
virtual ~ExtentCallbackInterface() = default;
279279

280+
virtual shard_stats_t& get_shard_stats() = 0;
281+
280282
/// Creates empty transaction
281283
/// weak transaction should be type READ
282284
virtual TransactionRef create_transaction(

0 commit comments

Comments
 (0)