<< ", uuid=" << header.uuid
<< ", block_size=" << header.block_size
<< ", size=" << header.size
- << ", start_offset=" << header.start_offset
+ << ", journal_tail=" << header.journal_tail
<< ", applied_to="<< header.applied_to
<< ", written_to=" << header.written_to
<< ", flsg=" << header.flag
CircularBoundedJournal::cbj_header_t head;
head.block_size = config.block_size;
head.size = config.total_size - device->get_block_size();
- head.start_offset = device->get_block_size();
- head.written_to = head.start_offset;
- head.applied_to = head.start_offset;
+ head.journal_tail = device->get_block_size();
+ head.written_to = head.journal_tail;
+ head.applied_to = head.journal_tail;
head.device_id = config.device_id;
start_dev_addr = config.start;
encode(head, bl);
auto fut = open_for_write(CBJOURNAL_START_ADDRESS);
return fut.safe_then([this, FNAME, delta_handler=std::move(delta_handler)] (auto addr) {
return seastar::do_with(
- rbm_abs_addr(get_applied_to()),
+ rbm_abs_addr(get_journal_tail()),
std::move(delta_handler),
segment_seq_t(),
[this, FNAME](auto &cursor_addr, auto &d_handler, auto &last_seq) {
* queue. With CBJournal, Seastore will append some of the records if the size
* of the record is small (most likely metadata), at which point the head
* (written_to) will be moved. Then, eventually, Seastore applies the records
- * in CBjournal to RBM---the tail (applied_to) is advanced (TODO).
+ * in CBjournal to RBM (TODO).
*
* - Commit time
* After submit_record is done, written_to is increased(this in-memory value)
*
* - Replay time
* At replay time, CBJournal begins to replay records in CBjournal by reading
- * records from applied_to. Then, CBJournal examines whether the records is valid
+ * records from journal_tail. Then, CBJournal examines whether the records is valid
* one by one, at which point written_to is recovered
- * if the valid record is founded. Note that only applied_to is stored
+ * if the valid record is founded. Note that applied_to is stored
* permanently when the apply work---applying the records in CBJournal to RBM---
* is done by CBJournal (TODO).
*
uint64_t block_size = 0; // block size of underlying device
uint64_t size = 0; // max length of journal
- // start offset of CircularBoundedJournal in the device (start + header length)
- rbm_abs_addr start_offset = 0;
+ // start offset of CircularBoundedJournal in the device
+ rbm_abs_addr journal_tail = 0;
// start address where the newest record will be written
rbm_abs_addr written_to = 0;
// address to represent where last appllied record is written
denc(v.block_size, p);
denc(v.size, p);
- denc(v.start_offset, p);
+ denc(v.journal_tail, p);
denc(v.written_to, p);
denc(v.applied_to, p);
*/
size_t get_used_size() const {
- return get_written_to() >= get_applied_to() ?
- get_written_to() - get_applied_to() :
- get_written_to() + get_total_size() - get_applied_to();
+ return get_written_to() >= get_journal_tail() ?
+ get_written_to() - get_journal_tail() :
+ get_written_to() + get_total_size() - get_journal_tail();
}
size_t get_total_size() const {
return header.size;
}
rbm_abs_addr get_start_addr() const {
- return header.start_offset;
+ return get_block_size();
}
size_t get_available_size() const {
return get_total_size() - get_used_size();
}
- void update_applied_to(rbm_abs_addr addr, uint32_t len) {
- set_applied_to(addr + len);
+ write_ertr::future<> update_journal_tail(rbm_abs_addr addr) {
+ header.journal_tail = addr;
+ return write_header();
+ }
+ rbm_abs_addr get_journal_tail() const {
+ return header.journal_tail;
}
write_ertr::future<> write_header();
void set_written_to(rbm_abs_addr addr) {
header.written_to = addr;
}
- rbm_abs_addr get_applied_to() const {
- return header.applied_to;
- }
- void set_applied_to(rbm_abs_addr addr) {
- header.applied_to = addr;
- }
device_id_t get_device_id() const {
return header.device_id;
}
auto get_written_to() {
return cbj->get_written_to();
}
- auto get_applied_to() {
- return cbj->get_applied_to();
+ auto get_journal_tail() {
+ return cbj->get_journal_tail();
}
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 update_journal_tail(rbm_abs_addr addr, uint32_t len) {
+ cbj->update_journal_tail(addr + len).unsafe_get0();
}
void set_written_to(rbm_abs_addr addr) {
cbj->set_written_to(addr);
}
uint64_t avail = get_available_size();
- update_applied_to(entries.back().addr, record_total_size);
+ update_journal_tail(entries.back().addr, record_total_size);
ASSERT_EQ(get_total_size(),
get_available_size());
}
uint64_t avail = get_available_size();
- update_applied_to(entries.front().addr, record_total_size);
+ update_journal_tail(entries.front().addr, record_total_size);
entries.erase(entries.begin());
ASSERT_EQ(avail + record_total_size, get_available_size());
avail = get_available_size();
auto record_total_size = r_size.get_encoded_length();
submit_record(std::move(rec));
- update_applied_to(entries.front().addr, record_total_size);
+ update_journal_tail(entries.front().addr, record_total_size);
cbj->write_header().unsafe_get0();
auto [update_header, update_buf2] = *(cbj->read_header(0).unsafe_get0());
replay();
- ASSERT_EQ(update_header.applied_to, update_header.applied_to);
+ ASSERT_EQ(update_header.journal_tail, update_header.journal_tail);
ASSERT_EQ(header.block_size, update_header.block_size);
ASSERT_EQ(header.size, update_header.size);
ASSERT_EQ(header.written_to + record_total_size, update_header.written_to);
}
// will be appended at the begining of WAL
uint64_t avail = get_available_size();
- update_applied_to(entries.front().addr, record_total_size);
+ update_journal_tail(entries.front().addr, record_total_size);
entries.erase(entries.begin());
ASSERT_EQ(avail + record_total_size, get_available_size());
avail = get_available_size();