]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
seastore/cbjournal: use journal_tail instead of applied_to to track journal tail
authormyoungwon oh <ohmyoungwon@gmail.com>
Fri, 6 May 2022 11:57:13 +0000 (20:57 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Thu, 19 May 2022 00:49:17 +0000 (09:49 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/journal/circular_bounded_journal.cc
src/crimson/os/seastore/journal/circular_bounded_journal.h
src/test/crimson/seastore/test_cbjournal.cc

index 68869c33ce246e190eca2a73a0cea4a8fa83987f..1629a4b69410b08b95859af0ec73da88e954066f 100644 (file)
@@ -19,7 +19,7 @@ std::ostream &operator<<(std::ostream &out,
             << ", 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
@@ -44,9 +44,9 @@ CircularBoundedJournal::mkfs(const mkfs_config_t& config)
     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);
@@ -347,7 +347,7 @@ Journal::replay_ret CircularBoundedJournal::replay(
   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) {
index a8292e556743d77f2a2f68f5e182fb51570fa64d..fee6eec0cbe3b8c40ff980aef2561dd1d8982152 100644 (file)
@@ -35,7 +35,7 @@ using NVMeBlockDevice = nvme_device::NVMeBlockDevice;
  * 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)
@@ -44,9 +44,9 @@ using NVMeBlockDevice = nvme_device::NVMeBlockDevice;
  *
  * - 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).
  *
@@ -208,8 +208,8 @@ public:
     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
@@ -227,7 +227,7 @@ public:
       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);
@@ -252,22 +252,26 @@ public:
    */
 
   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();
@@ -284,12 +288,6 @@ public:
   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;
   }
index e7fbf4129687ba9f3f4233269c4e86d4cfb3e1c2..191cc45ff5d9f5298c9772d70b343c5578f97b99 100644 (file)
@@ -248,14 +248,14 @@ struct cbjournal_test_t : public seastar_test_suite_t
   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);
@@ -322,7 +322,7 @@ TEST_F(cbjournal_test_t, submit_full_records)
     }
 
     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());
 
@@ -365,7 +365,7 @@ TEST_F(cbjournal_test_t, boudary_check_verify)
     }
 
     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();
@@ -394,12 +394,12 @@ TEST_F(cbjournal_test_t, update_header)
     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);
@@ -427,7 +427,7 @@ TEST_F(cbjournal_test_t, replay)
     }
     // 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();