#include "journal/segmented_journal.h"
#include "journal/circular_bounded_journal.h"
-namespace crimson::os::seastore::journal {
+namespace crimson::os::seastore {
+
+Journal::scan_alloc_map_ret
+Journal::scan_alloc_map() {
+ alloc_map_t map;
+ journal_seq_t tail = get_dirty_tail() <= get_alloc_tail() ?
+ get_dirty_tail() : get_alloc_tail();
+ auto build_paddr_seq_map = [&map](
+ const auto &offsets,
+ const auto &e,
+ sea_time_point modify_time)
+ {
+ if (e.type == extent_types_t::ALLOC_INFO) {
+ alloc_delta_t alloc_delta;
+ decode(alloc_delta, e.bl);
+ if (alloc_delta.op == alloc_delta_t::op_types_t::CLEAR) {
+ for (auto &alloc_blk : alloc_delta.alloc_blk_ranges) {
+ map[alloc_blk.paddr] = offsets.write_result.start_seq;
+ }
+ }
+ }
+ return replay_ertr::make_ready_future<bool>(true);
+ };
+ // build the paddr->journal_seq_t map from extent allocations
+ co_await scan_valid_record_delta(std::move(build_paddr_seq_map), tail);
+ co_return map;
+}
+
+namespace journal {
JournalRef make_segmented(
store_index_t store_index,
return std::make_unique<CircularBoundedJournal>(store_index, trimmer, device, path);
}
-}
+} // namespace journal
+
+} // namespace crimson::os::seastore
virtual backend_type_t get_type() = 0;
virtual bool is_checksum_needed() = 0;
+
+protected:
+ using alloc_map_t = std::map<paddr_t, journal_seq_t>;
+ using scan_alloc_map_ertr = replay_ertr;
+ using scan_alloc_map_ret = scan_alloc_map_ertr::future<alloc_map_t>;
+ scan_alloc_map_ret scan_alloc_map();
+
+ using scan_delta_handler_t = std::function<
+ replay_ertr::future<bool>(
+ const record_locator_t&,
+ const delta_info_t&,
+ sea_time_point modify_time)>;
+ virtual replay_ret scan_valid_record_delta(
+ scan_delta_handler_t &&delta_handler,
+ journal_seq_t tail) = 0;
+
+ virtual journal_seq_t get_dirty_tail() const = 0;
+ virtual journal_seq_t get_alloc_tail() const = 0;
};
using JournalRef = std::unique_ptr<Journal>;
}
Journal::replay_ret CircularBoundedJournal::replay_segment(
- cbj_delta_handler_t &handler, scan_valid_records_cursor& cursor)
+ scan_delta_handler_t &handler, scan_valid_records_cursor& cursor)
{
LOG_PREFIX(Journal::replay_segment);
return seastar::do_with(
Journal::replay_ret CircularBoundedJournal::scan_valid_record_delta(
- cbj_delta_handler_t &&handler, journal_seq_t tail)
+ scan_delta_handler_t &&handler, journal_seq_t tail)
{
LOG_PREFIX(Journal::scan_valid_record_delta);
INFO("starting at {} ", tail);
cjs.set_cbj_header(head);
DEBUG("header : {}", cjs.get_cbj_header());
cjs.set_initialized(true);
- std::map<paddr_t, journal_seq_t> map;
std::map<paddr_t, std::pair<CachedExtentRef, uint32_t>> crc_info;
auto tail = get_dirty_tail() <= get_alloc_tail() ?
get_dirty_tail() : get_alloc_tail();
return replay_ertr::make_ready_future<bool>(true);
};
co_await scan_valid_record_delta(std::move(find_tail), tail);
- tail = get_dirty_tail() <= get_alloc_tail() ?
- get_dirty_tail() : get_alloc_tail();
- auto build_paddr_seq_map = [&map](
- const auto &offsets,
- const auto &e,
- sea_time_point modify_time)
- {
- if (e.type == extent_types_t::ALLOC_INFO) {
- alloc_delta_t alloc_delta;
- decode(alloc_delta, e.bl);
- if (alloc_delta.op == alloc_delta_t::op_types_t::CLEAR) {
- for (auto &alloc_blk : alloc_delta.alloc_blk_ranges) {
- map[alloc_blk.paddr] = offsets.write_result.start_seq;
- }
- }
- }
- return replay_ertr::make_ready_future<bool>(true);
- };
// The second pass to build the paddr->journal_seq_t map
// from extent allocations
- co_await scan_valid_record_delta(std::move(build_paddr_seq_map), tail);
+ alloc_map_t map = co_await scan_alloc_map();
auto call_d_handler_if_valid = [this, &map, &d_handler, &crc_info](
const auto &offsets,
const auto &e,
return cjs.get_records_start();
}
- using cbj_delta_handler_t = std::function<
- replay_ertr::future<bool>(
- const record_locator_t&,
- const delta_info_t&,
- sea_time_point modify_time)>;
-
Journal::replay_ret scan_valid_record_delta(
- cbj_delta_handler_t &&delta_handler,
+ scan_delta_handler_t &&delta_handler,
journal_seq_t tail);
void try_read_rolled_header(scan_valid_records_cursor &cursor) {
};
Journal::replay_ret replay_segment(
- cbj_delta_handler_t &handler, scan_valid_records_cursor& cursor);
+ scan_delta_handler_t &handler, scan_valid_records_cursor& cursor);
read_ret read(paddr_t start, size_t len) final;
delta_handler_t &delta_handler, ///< [in] processes deltas in order
replay_stats_t &stats ///< [out] replay stats
);
+
+ journal_seq_t get_dirty_tail() const final {
+ return trimmer.get_dirty_tail();
+ }
+
+ journal_seq_t get_alloc_tail() const final {
+ return trimmer.get_alloc_tail();
+ }
+
+ replay_ret scan_valid_record_delta(
+ scan_delta_handler_t &&delta_handler,
+ journal_seq_t tail) final {
+ return replay_ertr::now();
+ }
};
}