paddr_t paddr = convert_abs_addr_to_paddr(
get_written_to(),
header.device_id);
+ header.size = header.end - header.start - get_block_size();
init = true;
return open_for_write_ret(
open_for_write_ertr::ready_future_marker{},
LOG_PREFIX(CircularBoundedJournal::replay);
auto fut = open_for_write(CBJOURNAL_START_ADDRESS);
return fut.safe_then([this, FNAME, delta_handler=std::move(delta_handler)] (auto addr) {
- if (get_used_size() == 0) {
- return replay_ertr::now();
- }
return seastar::do_with(
rbm_abs_addr(get_applied_to()),
std::move(delta_handler),
cursor_addr += bl.length();
set_written_to(cursor_addr);
last_seq = r_header.committed_to.segment_seq;
+ set_used_size(get_used_size() + bl.length());
return seastar::do_with(
std::move(*maybe_record_deltas_list),
[write_result,
auto get_applied_to() {
return cbj->get_applied_to();
}
+ auto get_used_size() {
+ return cbj->get_used_size();
+ }
void update_applied_to(rbm_abs_addr addr, uint32_t len) {
cbj->update_applied_to(addr, len);
}
void set_written_to(rbm_abs_addr addr) {
cbj->set_written_to(addr);
}
+ void set_used_size(size_t size) {
+ cbj->set_used_size(size);
+ }
};
TEST_F(cbjournal_test_t, submit_one_record)
auto record_total_size = r_size.get_encoded_length();
submit_record(std::move(rec));
- cbj->write_header().unsafe_get0();
- auto [update_header, update_buf] = *(cbj->read_header(0).unsafe_get0());
-
- ASSERT_EQ(header.size, update_header.size);
- ASSERT_EQ(header.used_size + record_total_size, update_header.used_size);
-
update_applied_to(entries.front().addr, record_total_size);
cbj->write_header().unsafe_get0();
- auto [update_header2, update_buf2] = *(cbj->read_header(0).unsafe_get0());
+ auto [update_header, update_buf2] = *(cbj->read_header(0).unsafe_get0());
+ replay();
- ASSERT_EQ(header.used_size, update_header2.used_size);
- ASSERT_EQ(header.written_to + record_total_size, update_header2.written_to);
+ ASSERT_EQ(update_header.applied_to, update_header.applied_to);
+ ASSERT_EQ(header.block_size, update_header.block_size);
+ ASSERT_EQ(header.start, update_header.start);
+ ASSERT_EQ(header.end, update_header.end);
+ ASSERT_EQ(header.size, update_header.size);
+ ASSERT_EQ(header.used_size, update_header.used_size);
+ ASSERT_EQ(header.written_to + record_total_size, update_header.written_to);
ASSERT_EQ(header.last_committed_record_base + block_size,
- update_header2.last_committed_record_base);
+ update_header.last_committed_record_base);
});
}
}
auto old_written_to = get_written_to();
auto old_last_committed_record_base = get_last_committed_record_base();
+ auto old_used_size = get_used_size();
set_written_to(4096);
set_last_committed_record_base(4096);
+ set_used_size(0);
replay();
ASSERT_EQ(old_written_to, get_written_to());
ASSERT_EQ(old_last_committed_record_base,
get_last_committed_record_base());
+ ASSERT_EQ(old_used_size,
+ get_used_size());
});
}