]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cbj: add get_journal_start() and adjust it to default block size
authormyoungwon oh <ohmyoungwon@gmail.com>
Tue, 18 Oct 2022 01:48:05 +0000 (10:48 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Wed, 19 Oct 2022 08:18:47 +0000 (17:18 +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/crimson/os/seastore/random_block_manager/rbm_device.h
src/crimson/os/seastore/transaction_manager.cc
src/test/crimson/seastore/test_cbjournal.cc
src/test/crimson/seastore/transaction_manager_test_state.h

index ed1d3aaa69a182f0eaf1da472262963bfea9194d..241c897e1870eda1695a6b5d8418ba3fb8dd700a 100644 (file)
@@ -56,7 +56,7 @@ CircularBoundedJournal::open_for_mkfs()
   head.dirty_tail =
     journal_seq_t{0,
       convert_abs_addr_to_paddr(
-       device->get_block_size(),
+       get_start_addr(),
        device->get_device_id())};
   head.alloc_tail = head.dirty_tail;
   encode(head, bl);
@@ -208,10 +208,11 @@ CircularBoundedJournal::read_header_ret
 CircularBoundedJournal::read_header()
 {
   LOG_PREFIX(CircularBoundedJournal::read_header);
+  assert(device);
   auto bptr = bufferptr(ceph::buffer::create_page_aligned(
                        device->get_block_size()));
-  DEBUG("reading {}", CBJOURNAL_START_ADDRESS);
-  return device->read(CBJOURNAL_START_ADDRESS, bptr
+  DEBUG("reading {}", device->get_journal_start());
+  return device->read(device->get_journal_start(), bptr
   ).safe_then([bptr, FNAME]() mutable
     -> read_header_ret {
     bufferlist bl;
@@ -465,7 +466,8 @@ CircularBoundedJournal::write_header()
   DEBUG(
     "sync header of CircularBoundedJournal, length {}",
     bl.length());
-  return device_write_bl(CBJOURNAL_START_ADDRESS, bl);
+  assert(device);
+  return device_write_bl(device->get_journal_start(), bl);
 }
 seastar::future<> CircularBoundedJournal::finish_commit(transaction_type_t type) {
   if (is_trim_transaction(type)) {
index 0f3ac8aeee671ae424df05aaa4bee94dc0d691a0..34cd1268ebf4511ed7d08dc1d8636ec657677c60 100644 (file)
@@ -22,7 +22,6 @@
 
 namespace crimson::os::seastore::journal {
 
-constexpr rbm_abs_addr CBJOURNAL_START_ADDRESS = 0;
 using RBMDevice = random_block_device::RBMDevice;
 
 /**
@@ -195,7 +194,8 @@ public:
     return device->get_journal_size() - get_block_size();
   }
   rbm_abs_addr get_start_addr() const {
-    return CBJOURNAL_START_ADDRESS + get_block_size();
+    assert(device);
+    return device->get_journal_start() + get_block_size();
   }
   size_t get_available_size() const {
     return get_total_size() - get_used_size();
index 3203208670ed30ee74f01dace7406fb6645c910c..d5604fe420a288f8926925c61b15b7ce5e885c62 100644 (file)
@@ -171,6 +171,10 @@ public:
   void set_journal_size(uint64_t size) {
     super.journal_size = size;
   }
+
+  static rbm_abs_addr get_journal_start() {
+    return RBM_SUPERBLOCK_SIZE;
+  }
 };
 
 class TestMemory : public RBMDevice {
index 28da43bbb7058243bc29bb5a333b48c471066f06..32143ef555599cb09f87194fa021c1b02555f1ba 100644 (file)
@@ -648,11 +648,11 @@ TransactionManagerRef make_transaction_manager(
     roll_size = static_cast<SegmentManager*>(primary_device)->get_segment_size();
     roll_start = 0;
   } else {
-    // FIXME: get from runtime configration instead of static defaults
-    roll_size = journal::DEFAULT_TEST_CBJOURNAL_SIZE;
+    roll_size = static_cast<random_block_device::RBMDevice*>(primary_device)
+               ->get_journal_size();
     // see CircularBoundedJournal::get_start_addr()
-    roll_start = journal::CBJOURNAL_START_ADDRESS +
-                 primary_device->get_block_size();
+    roll_start = static_cast<random_block_device::RBMDevice*>(primary_device)
+                ->get_journal_start() + primary_device->get_block_size();
     ceph_assert_always(roll_size <= DEVICE_OFF_MAX);
     ceph_assert_always((std::size_t)roll_size + roll_start <=
                        primary_device->get_available_size());
index 529e782a111bc021d2e3c023a134dbfd3202c22e..295dc8c5c6e388c18737232ed92daa46db4d3e5c 100644 (file)
@@ -133,7 +133,8 @@ struct cbjournal_test_t : public seastar_test_suite_t, JournalTrimmer
 
   cbjournal_test_t() {
     device = new random_block_device::TestMemory(
-      CBTEST_DEFAULT_TEST_SIZE + CBTEST_DEFAULT_BLOCK_SIZE,
+      CBTEST_DEFAULT_TEST_SIZE + CBTEST_DEFAULT_BLOCK_SIZE +
+      random_block_device::RBMDevice::get_journal_start(),
       CBTEST_DEFAULT_BLOCK_SIZE);
     cbj.reset(new CircularBoundedJournal(*this, device, std::string()));
     block_size = CBTEST_DEFAULT_BLOCK_SIZE;
@@ -504,7 +505,7 @@ TEST_F(cbjournal_test_t, replay_after_reset)
     set_written_to(
       journal_seq_t{0,
        convert_abs_addr_to_paddr(
-         4096,
+         cbj->get_start_addr(),
          cbj->get_device_id())});
     cbj->close().unsafe_get0();
     replay();
index f346a5d12548f957a4b24486cb68722e4d7a9355..86ed6f2d734ea0ee16929b675a5ff9d91246313e 100644 (file)
@@ -118,7 +118,8 @@ protected:
   seastar::future<> randomblock_setup()
   {
     rb_device.reset(new random_block_device::TestMemory(
-          journal::DEFAULT_TEST_CBJOURNAL_SIZE + journal::DEFAULT_BLOCK_SIZE,
+          journal::DEFAULT_TEST_CBJOURNAL_SIZE + journal::DEFAULT_BLOCK_SIZE +
+         random_block_device::RBMDevice::get_journal_start(),
          journal::DEFAULT_BLOCK_SIZE));
     return rb_device->mount().handle_error(crimson::ct_error::assert_all{}
     ).then([this]() {