summaryrefslogtreecommitdiffstats
path: root/src/crimson
diff options
context:
space:
mode:
authorXuehan Xu <xuxuehan@qianxin.com>2024-07-24 15:17:43 +0200
committerXuehan Xu <xuxuehan@qianxin.com>2024-08-05 08:16:12 +0200
commita5329cbbaa2380dc76fdd8451a0560673e13e35b (patch)
tree0c6a4dd80ccd3b4c6b528562613f569aab91748d /src/crimson
parentMerge pull request #58718 from wanglinke521/wlk-kv-stats (diff)
downloadceph-a5329cbbaa2380dc76fdd8451a0560673e13e35b.tar.xz
ceph-a5329cbbaa2380dc76fdd8451a0560673e13e35b.zip
crimson/os/seastore: consider segment_header_t::modify_time as the
segments' modify_time for no-tail OOL segments OOL segments don't contain record headers anymore, we use segment_header_t::modify_time as the approximation of segment modify_time Fixes: https://tracker.ceph.com/issues/67106 Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
Diffstat (limited to 'src/crimson')
-rw-r--r--src/crimson/os/seastore/async_cleaner.cc55
-rw-r--r--src/crimson/os/seastore/async_cleaner.h17
-rw-r--r--src/crimson/os/seastore/journal/segment_allocator.cc1
-rw-r--r--src/crimson/os/seastore/seastore_types.cc1
-rw-r--r--src/crimson/os/seastore/seastore_types.h3
5 files changed, 63 insertions, 14 deletions
diff --git a/src/crimson/os/seastore/async_cleaner.cc b/src/crimson/os/seastore/async_cleaner.cc
index 7e13befde0d..5046980eae5 100644
--- a/src/crimson/os/seastore/async_cleaner.cc
+++ b/src/crimson/os/seastore/async_cleaner.cc
@@ -1372,20 +1372,33 @@ SegmentCleaner::mount_ret SegmentCleaner::mount()
segment_id
).safe_then([this, FNAME, segment_id, header](auto tail)
-> scan_extents_ertr::future<> {
- if (tail.segment_nonce != header.segment_nonce) {
+ bool tail_valid = (tail.segment_nonce == header.segment_nonce);
+ if (!tail_valid && header.type == segment_type_t::JOURNAL) {
return scan_no_tail_segment(header, segment_id);
}
- ceph_assert(header.get_type() == tail.get_type());
-
- sea_time_point modify_time = mod_to_timepoint(tail.modify_time);
- std::size_t num_extents = tail.num_extents;
- if ((modify_time == NULL_TIME && num_extents == 0) ||
- (modify_time != NULL_TIME && num_extents != 0)) {
- segments.update_modify_time(segment_id, modify_time, num_extents);
- } else {
- ERROR("illegal modify time {}", tail);
- return crimson::ct_error::input_output_error::make();
- }
+ ceph_assert(header.get_type() == tail.get_type() || !tail_valid);
+
+ sea_time_point header_time = mod_to_timepoint(header.modify_time);
+ if (tail_valid) {
+ sea_time_point tail_time = mod_to_timepoint(tail.modify_time);
+ std::size_t num_extents = tail.num_extents;
+ DEBUG("updating modify time for segment {}, "
+ "mod time {}-{}, num_extents {}",
+ segment_id, header_time, tail_time, num_extents);
+ if (num_extents == 0) {
+ ceph_assert(tail_time == NULL_TIME);
+ } else {
+ ceph_assert(header_time != NULL_TIME);
+ ceph_assert(tail_time != NULL_TIME);
+ sea_time_point avg_time = get_average_time(
+ header_time, 1, tail_time, 1);
+ segments.update_modify_time(segment_id, avg_time, num_extents);
+ }
+ } else {
+ DEBUG("updating modify time for segment {}, mod time {}, without tail",
+ segment_id, header_time);
+ segments.init_modify_time(segment_id, header_time);
+ }
init_mark_segment_closed(
segment_id,
@@ -1396,8 +1409,22 @@ SegmentCleaner::mount_ret SegmentCleaner::mount()
return seastar::now();
}).handle_error(
crimson::ct_error::enodata::handle(
- [this, header, segment_id](auto) {
- return scan_no_tail_segment(header, segment_id);
+ [this, header, segment_id, FNAME](auto) {
+ if (header.type == segment_type_t::JOURNAL) {
+ return scan_no_tail_segment(header, segment_id);
+ } else {
+ sea_time_point modify_time = mod_to_timepoint(header.modify_time);
+ DEBUG("updating modify time for segment {}, mod time {}",
+ segment_id, modify_time);
+ segments.init_modify_time(segment_id, modify_time);
+ init_mark_segment_closed(
+ segment_id,
+ header.segment_seq,
+ header.type,
+ header.category,
+ header.generation);
+ return scan_extents_ertr::now();
+ }
}),
crimson::ct_error::pass_further_all{}
);
diff --git a/src/crimson/os/seastore/async_cleaner.h b/src/crimson/os/seastore/async_cleaner.h
index adf9fb177ad..485497b9a9c 100644
--- a/src/crimson/os/seastore/async_cleaner.h
+++ b/src/crimson/os/seastore/async_cleaner.h
@@ -43,6 +43,7 @@ struct segment_info_t {
sea_time_point modify_time = NULL_TIME;
+ // Might be unavailable(0), see mount() -> init_modify_time()
std::size_t num_extents = 0;
segment_off_t written_to = 0;
@@ -75,6 +76,13 @@ struct segment_info_t {
void set_closed();
+ void init_modify_time(sea_time_point _modify_time) {
+ ceph_assert(modify_time == NULL_TIME);
+ ceph_assert(num_extents == 0);
+ ceph_assert(_modify_time != NULL_TIME);
+ modify_time = _modify_time;
+ }
+
void update_modify_time(sea_time_point _modify_time, std::size_t _num_extents) {
ceph_assert(!is_closed());
assert(_modify_time != NULL_TIME);
@@ -226,6 +234,15 @@ public:
void update_written_to(segment_type_t, paddr_t);
+ void init_modify_time(
+ segment_id_t id, sea_time_point tp) {
+ if (tp == NULL_TIME) {
+ return;
+ }
+
+ segments[id].init_modify_time(tp);
+ }
+
void update_modify_time(
segment_id_t id, sea_time_point tp, std::size_t num) {
if (num == 0) {
diff --git a/src/crimson/os/seastore/journal/segment_allocator.cc b/src/crimson/os/seastore/journal/segment_allocator.cc
index 61e1be585c8..7760c869b49 100644
--- a/src/crimson/os/seastore/journal/segment_allocator.cc
+++ b/src/crimson/os/seastore/journal/segment_allocator.cc
@@ -93,6 +93,7 @@ SegmentAllocator::do_open(bool is_mkfs)
alloc_tail = JOURNAL_SEQ_NULL;
}
auto header = segment_header_t{
+ timepoint_to_mod(seastar::lowres_system_clock::now()),
new_segment_seq,
segment_id,
dirty_tail,
diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc
index 25d787f0fd3..5481a680f27 100644
--- a/src/crimson/os/seastore/seastore_types.cc
+++ b/src/crimson/os/seastore/seastore_types.cc
@@ -371,6 +371,7 @@ std::ostream &operator<<(std::ostream &out, const segment_header_t &header)
<< ", dirty_tail=" << header.dirty_tail
<< ", alloc_tail=" << header.alloc_tail
<< ", segment_nonce=" << header.segment_nonce
+ << ", modify_time=" << mod_time_point_printer_t{header.modify_time}
<< ")";
}
diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h
index dc2f478136e..35c331d5096 100644
--- a/src/crimson/os/seastore/seastore_types.h
+++ b/src/crimson/os/seastore/seastore_types.h
@@ -1799,6 +1799,8 @@ using segment_nonce_t = uint32_t;
* 4) Replay from the latest tails
*/
struct segment_header_t {
+ mod_time_point_t modify_time;
+
segment_seq_t segment_seq;
segment_id_t physical_segment_id; // debugging
@@ -1817,6 +1819,7 @@ struct segment_header_t {
DENC(segment_header_t, v, p) {
DENC_START(1, 1, p);
+ denc(v.modify_time, p);
denc(v.segment_seq, p);
denc(v.physical_segment_id, p);
denc(v.dirty_tail, p);