From: Yingxin Cheng Date: Mon, 4 Jul 2022 08:14:00 +0000 (+0800) Subject: crimson/os/seastore/circular_bounded_journal: simplify RBM start as a hard-coded... X-Git-Tag: v18.0.0~552^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2c3062537fe8836ec74ce3664da6cc47f760adf1;p=ceph.git crimson/os/seastore/circular_bounded_journal: simplify RBM start as a hard-coded position Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.cc b/src/crimson/os/seastore/journal/circular_bounded_journal.cc index 8f0b047f86b4c..9722200a33542 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.cc +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.cc @@ -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); } } diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.h b/src/crimson/os/seastore/journal/circular_bounded_journal.h index e69c8c6b6b127..4902729c48bd8 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.h +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.h @@ -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::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; }; diff --git a/src/test/crimson/seastore/test_cbjournal.cc b/src/test/crimson/seastore/test_cbjournal.cc index b4dc8b4aed7df..a389301b281fe 100644 --- a/src/test/crimson/seastore/test_cbjournal.cc +++ b/src/test/crimson/seastore/test_cbjournal.cc @@ -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::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(); diff --git a/src/test/crimson/seastore/transaction_manager_test_state.h b/src/test/crimson/seastore/transaction_manager_test_state.h index 19b5b08cdf3a8..ed5bdef02fca6 100644 --- a/src/test/crimson/seastore/transaction_manager_test_state.h +++ b/src/test/crimson/seastore/transaction_manager_test_state.h @@ -209,8 +209,8 @@ protected: config ).safe_then([this]() { return static_cast(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"}