]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/circular_bounded_journal: simplify RBM start as a hard-coded...
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 4 Jul 2022 08:14:00 +0000 (16:14 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 6 Jul 2022 01:29:38 +0000 (09:29 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.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
src/test/crimson/seastore/transaction_manager_test_state.h

index 8f0b047f86b4cae9d5f2e6a8f149f6926e089a52..9722200a335425e09e94d82a752fb918aaba19aa 100644 (file)
@@ -45,7 +45,6 @@ CircularBoundedJournal::mkfs(const mkfs_config_t& config)
     head.journal_tail = device->get_block_size();
     head.applied_to = head.journal_tail;
     head.device_id = config.device_id;
-    start_dev_addr = config.start;
     encode(head, bl);
     header = head;
     written_to = head.journal_tail;
@@ -130,25 +129,24 @@ CircularBoundedJournal::close_ertr::future<> CircularBoundedJournal::close()
 }
 
 CircularBoundedJournal::open_for_write_ret
-CircularBoundedJournal::open_device_read_header(rbm_abs_addr start)
+CircularBoundedJournal::open_device_read_header()
 {
   LOG_PREFIX(CircularBoundedJournal::open_for_write);
   ceph_assert(!initialized);
   return _open_device(path
-  ).safe_then([this, start, FNAME]() {
-    return read_header(start
+  ).safe_then([this, FNAME]() {
+    return read_header(
     ).handle_error(
       open_for_write_ertr::pass_further{},
       crimson::ct_error::assert_all{
        "Invalid error read_header"
-    }).safe_then([this, start, FNAME](auto p) mutable {
+    }).safe_then([this, FNAME](auto p) mutable {
       auto &[head, bl] = *p;
       header = head;
       DEBUG("header : {}", header);
       paddr_t paddr = convert_abs_addr_to_paddr(
        get_written_to(),
        header.device_id);
-      start_dev_addr = start;
       initialized = true;
       return open_for_write_ret(
        open_for_write_ertr::ready_future_marker{},
@@ -314,15 +312,15 @@ CircularBoundedJournal::write_ertr::future<> CircularBoundedJournal::device_writ
 }
 
 CircularBoundedJournal::read_header_ret
-CircularBoundedJournal::read_header(rbm_abs_addr start)
+CircularBoundedJournal::read_header()
 {
   LOG_PREFIX(CircularBoundedJournal::read_header);
   auto bptr = bufferptr(ceph::buffer::create_page_aligned(
                        device->get_block_size()));
-  return device->read(start, bptr
-  ).safe_then([start, bptr, FNAME]() mutable
+  DEBUG("reading {}", CBJOURNAL_START_ADDRESS);
+  return device->read(CBJOURNAL_START_ADDRESS, bptr
+  ).safe_then([bptr, FNAME]() mutable
     -> read_header_ret {
-    DEBUG("read_header: reading {}", start);
     bufferlist bl;
     bl.append(bptr);
     auto bp = bl.cbegin();
@@ -360,7 +358,7 @@ Journal::replay_ret CircularBoundedJournal::replay(
    * read records from last applied record prior to written_to, and replay
    */
   LOG_PREFIX(CircularBoundedJournal::replay);
-  auto fut = open_device_read_header(CBJOURNAL_START_ADDRESS);
+  auto fut = open_device_read_header();
   return fut.safe_then([this, FNAME, delta_handler=std::move(delta_handler)] (auto addr) {
     return seastar::do_with(
       rbm_abs_addr(get_journal_tail()),
@@ -579,11 +577,11 @@ CircularBoundedJournal::write_header()
     DEBUG("unable to encode header block from underlying deivce");
     return crimson::ct_error::input_output_error::make();
   }
-  ceph_assert(bl.length() + sizeof(checksum_t) < get_block_size());
+  ceph_assert(bl.length() <= get_block_size());
   DEBUG(
     "sync header of CircularBoundedJournal, length {}",
     bl.length());
-  return device_write_bl(start_dev_addr, bl);
+  return device_write_bl(CBJOURNAL_START_ADDRESS, bl);
 }
 
 }
index e69c8c6b6b127d77b9c2b7781daf457228311694..4902729c48bd8b3d197eeaddd6bf460274e12228 100644 (file)
@@ -61,7 +61,6 @@ class CircularBoundedJournal : public Journal {
 public:
   struct mkfs_config_t {
     std::string path;
-    rbm_abs_addr start = 0;
     size_t block_size = 0;
     size_t total_size = 0;
     device_id_t device_id = 0;
@@ -70,7 +69,6 @@ public:
       device_id_t d_id = 1 << (std::numeric_limits<device_id_t>::digits - 1);
       return mkfs_config_t {
        "",
-       0,
        DEFAULT_BLOCK_SIZE,
        DEFAULT_SIZE,
        d_id,
@@ -83,7 +81,7 @@ public:
   ~CircularBoundedJournal() {}
 
   open_for_write_ret open_for_write() final;
-  open_for_write_ret open_device_read_header(rbm_abs_addr start);
+  open_for_write_ret open_device_read_header();
   close_ertr::future<> close() final;
 
   journal_type_t get_type() final {
@@ -159,7 +157,7 @@ public:
    * @param absolute address
    *
    */
-  read_header_ret read_header(rbm_abs_addr start);
+  read_header_ret read_header();
 
   ceph::bufferlist encode_header();
 
@@ -252,7 +250,7 @@ public:
     return header.size;
   }
   rbm_abs_addr get_start_addr() const {
-    return get_block_size();
+    return CBJOURNAL_START_ADDRESS + get_block_size();
   }
   size_t get_available_size() const {
     return get_total_size() - get_used_size();
@@ -287,7 +285,7 @@ public:
     return header.block_size;
   }
   rbm_abs_addr get_journal_end() const {
-    return header.size + get_block_size(); // journal size + header length
+    return get_start_addr() + header.size; // journal size + header length
   }
   void add_device(NVMeBlockDevice* dev) {
     device = dev;
@@ -305,7 +303,6 @@ private:
    */
   bool initialized = false;
   segment_seq_t cur_segment_seq = 0; // segment seq to track the sequence to written records
-  rbm_abs_addr start_dev_addr = 0; // cbjournal start address in device
   // start address where the newest record will be written
   rbm_abs_addr written_to = 0;
 };
index b4dc8b4aed7df4730704daf1b096551619957bb8..a389301b281feb398f8ee285a823370931cfcb1e 100644 (file)
@@ -141,7 +141,6 @@ struct cbjournal_test_t : public seastar_test_suite_t
     device = new nvme_device::TestMemory(CBTEST_DEFAULT_TEST_SIZE);
     cbj.reset(new CircularBoundedJournal(device, std::string()));
     device_id_t d_id = 1 << (std::numeric_limits<device_id_t>::digits - 1);
-    config.start = 0;
     config.block_size = CBTEST_DEFAULT_BLOCK_SIZE;
     config.total_size = CBTEST_DEFAULT_TEST_SIZE;
     config.device_id = d_id;
@@ -234,7 +233,7 @@ struct cbjournal_test_t : public seastar_test_suite_t
     return cbj->mkfs(config).unsafe_get0();
   }
   auto open() {
-    return cbj->open_device_read_header(config.start).unsafe_get0();
+    return cbj->open_device_read_header().unsafe_get0();
   }
   auto get_available_size() {
     return cbj->get_available_size();
@@ -385,7 +384,7 @@ TEST_F(cbjournal_test_t, update_header)
   run_async([this] {
     mkfs();
     open();
-    auto [header, _buf] = *(cbj->read_header(0).unsafe_get0());
+    auto [header, _buf] = *(cbj->read_header().unsafe_get0());
     record_t rec {
      { generate_extent(1), generate_extent(2) },
      { generate_delta(20), generate_delta(21) }
@@ -396,7 +395,7 @@ TEST_F(cbjournal_test_t, update_header)
 
     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());
+    auto [update_header, update_buf2] = *(cbj->read_header().unsafe_get0());
     cbj->close().unsafe_get0();
     replay();
 
index 19b5b08cdf3a875f5cac04264d6d72a1f07fe3de..ed5bdef02fca6c1b667d34c17d9df2c74eb7965d 100644 (file)
@@ -209,8 +209,8 @@ protected:
        config
       ).safe_then([this]() {
        return static_cast<journal::CircularBoundedJournal*>(tm->get_journal())->
-         open_device_read_header(journal::CBJOURNAL_START_ADDRESS
-       ).safe_then([this](auto addr) {
+         open_device_read_header(
+       ).safe_then([this](auto) {
          return tm->mkfs(
          ).handle_error(
            crimson::ct_error::assert_all{"Error in mkfs"}