diff options
author | Yingxin <yingxin.cheng@intel.com> | 2024-08-08 08:16:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 08:16:26 +0200 |
commit | 44fc9fa8023830c4cbcbf82bf5f7d4dba4547087 (patch) | |
tree | 5b616199badefe32ec1c8cf1f63bec1f0ce78a5d /src/crimson | |
parent | Merge pull request #57911 from gardran/wip-gdran-mds-better-clease-handling (diff) | |
parent | crimson/os/seastore: consider segment_header_t::modify_time as the (diff) | |
download | ceph-44fc9fa8023830c4cbcbf82bf5f7d4dba4547087.tar.xz ceph-44fc9fa8023830c4cbcbf82bf5f7d4dba4547087.zip |
Merge pull request #58787 from xxhdx1985126/wip-67106
crimson/os/seastore: consider segment_header_t::modify_time as the segments' modify_time for no-tail OOL segments
Reviewed-by: Yingxin Cheng <yingxin.cheng@intel.com>
Diffstat (limited to 'src/crimson')
-rw-r--r-- | src/crimson/os/seastore/async_cleaner.cc | 55 | ||||
-rw-r--r-- | src/crimson/os/seastore/async_cleaner.h | 17 | ||||
-rw-r--r-- | src/crimson/os/seastore/journal/segment_allocator.cc | 1 | ||||
-rw-r--r-- | src/crimson/os/seastore/seastore_types.cc | 1 | ||||
-rw-r--r-- | src/crimson/os/seastore/seastore_types.h | 3 |
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 a90d02e4fcd..424247c5bdc 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); |