From 8a8c89d9403b5d0aca3ee6e562a7ce676f2636b2 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Sat, 9 Apr 2022 22:32:32 +0900 Subject: [PATCH] seastore: rename *_super to *_header and use it as helper functions Signed-off-by: Myoungwon Oh --- .../journal/circular_bounded_journal.cc | 38 +++++++++---------- .../journal/circular_bounded_journal.h | 14 +++---- src/test/crimson/seastore/test_cbjournal.cc | 12 +++--- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.cc b/src/crimson/os/seastore/journal/circular_bounded_journal.cc index cc45e933c4bb8..738b5557fc9ab 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.cc +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.cc @@ -66,7 +66,7 @@ CircularBoundedJournal::mkfs(const mkfs_config_t& config) DEBUG( "initialize header block in CircularBoundedJournal, length {}", bl.length()); - return device_write_bl(start_addr, bl + return write_header( ).handle_error( mkfs_ertr::pass_further{}, crimson::ct_error::assert_all{ @@ -98,7 +98,7 @@ CircularBoundedJournal::_open_device(const std::string path) ); } -ceph::bufferlist CircularBoundedJournal::encode_super() +ceph::bufferlist CircularBoundedJournal::encode_header() { bufferlist bl; encode(header, bl); @@ -112,14 +112,14 @@ CircularBoundedJournal::open_for_write_ret CircularBoundedJournal::open_for_writ CircularBoundedJournal::close_ertr::future<> CircularBoundedJournal::close() { - return write_super( + return write_header( ).safe_then([this]() -> close_ertr::future<> { init = false; return device->close(); }).handle_error( open_for_write_ertr::pass_further{}, crimson::ct_error::assert_all{ - "Invalid error write_super" + "Invalid error write_header" } ); } @@ -141,15 +141,15 @@ CircularBoundedJournal::open_for_write(rbm_abs_addr start) } return _open_device(path ).safe_then([this, start, FNAME]() { - return read_super(start + return read_header(start ).handle_error( open_for_write_ertr::pass_further{}, crimson::ct_error::assert_all{ - "Invalid error read_super" + "Invalid error read_header" }).safe_then([this, FNAME](auto p) mutable { auto &[head, bl] = *p; header = head; - DEBUG("super : {}", header); + DEBUG("header : {}", header); paddr_t paddr = convert_abs_addr_to_paddr( get_written_to(), header.device_id); @@ -324,16 +324,16 @@ CircularBoundedJournal::write_ertr::future<> CircularBoundedJournal::device_writ }); } -CircularBoundedJournal::read_super_ret -CircularBoundedJournal::read_super(rbm_abs_addr start) +CircularBoundedJournal::read_header_ret +CircularBoundedJournal::read_header(rbm_abs_addr start) { - LOG_PREFIX(CircularBoundedJournal::read_super); + 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 - -> read_super_ret { - DEBUG("read_super: reading {}", start); + -> read_header_ret { + DEBUG("read_header: reading {}", start); bufferlist bl; bl.append(bptr); auto bp = bl.cbegin(); @@ -341,11 +341,11 @@ CircularBoundedJournal::read_super(rbm_abs_addr start) try { decode(cbj_header, bp); } catch (ceph::buffer::error &e) { - ERROR("read_super: unable to read super block"); + ERROR("read_header: unable to read header block"); return crimson::ct_error::enoent::make(); } - return read_super_ret( - read_super_ertr::ready_future_marker{}, + return read_header_ret( + read_header_ertr::ready_future_marker{}, std::make_pair(cbj_header, bl) ); }); @@ -562,14 +562,14 @@ CircularBoundedJournal::read_record_ret CircularBoundedJournal::read_record(padd } CircularBoundedJournal::write_ertr::future<> -CircularBoundedJournal::write_super() +CircularBoundedJournal::write_header() { - LOG_PREFIX(CircularBoundedJournal::write_super); + LOG_PREFIX(CircularBoundedJournal::write_header); ceph::bufferlist bl; try { - bl = encode_super(); + bl = encode_header(); } catch (ceph::buffer::error &e) { - DEBUG("unable to encode super block from underlying deivce"); + DEBUG("unable to encode header block from underlying deivce"); return crimson::ct_error::input_output_error::make(); } DEBUG( diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.h b/src/crimson/os/seastore/journal/circular_bounded_journal.h index 94b923bc9cd1e..71282d412042f 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.h +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.h @@ -120,8 +120,8 @@ public: using read_record_ret = read_record_ertr::future< std::optional> >; - using read_super_ertr = read_ertr; - using read_super_ret = read_super_ertr::future< + using read_header_ertr = read_ertr; + using read_header_ret = read_header_ertr::future< std::optional> >; /* @@ -134,16 +134,16 @@ public: */ read_record_ret read_record(paddr_t offset); /* - * read_super + * read_header * - * read super block from given absolute address + * read header block from given absolute address * * @param absolute address * */ - read_super_ret read_super(rbm_abs_addr start); + read_header_ret read_header(rbm_abs_addr start); - ceph::bufferlist encode_super(); + ceph::bufferlist encode_header(); using mkfs_ertr = crimson::errorator< crimson::ct_error::input_output_error, @@ -269,7 +269,7 @@ public: set_applied_to(new_applied_to + len); } - write_ertr::future<> write_super(); + write_ertr::future<> write_header(); read_record_ret return_record(record_group_header_t& header, bufferlist bl); diff --git a/src/test/crimson/seastore/test_cbjournal.cc b/src/test/crimson/seastore/test_cbjournal.cc index 13da9fc0a4071..af4b9dea0c02e 100644 --- a/src/test/crimson/seastore/test_cbjournal.cc +++ b/src/test/crimson/seastore/test_cbjournal.cc @@ -377,12 +377,12 @@ TEST_F(cbjournal_test_t, boudary_check_verify) }); } -TEST_F(cbjournal_test_t, update_super) +TEST_F(cbjournal_test_t, update_header) { run_async([this] { mkfs(); open(); - auto [header, _buf] = *(cbj->read_super(0).unsafe_get0()); + auto [header, _buf] = *(cbj->read_header(0).unsafe_get0()); record_t rec { { generate_extent(1), generate_extent(2) }, { generate_delta(20), generate_delta(21) } @@ -391,15 +391,15 @@ TEST_F(cbjournal_test_t, update_super) auto record_total_size = r_size.get_encoded_length(); submit_record(std::move(rec)); - cbj->write_super().unsafe_get0(); - auto [update_header, update_buf] = *(cbj->read_super(0).unsafe_get0()); + cbj->write_header().unsafe_get0(); + auto [update_header, update_buf] = *(cbj->read_header(0).unsafe_get0()); ASSERT_EQ(header.size, update_header.size); ASSERT_EQ(header.used_size + record_total_size, update_header.used_size); update_applied_to(entries.front().addr, record_total_size); - cbj->write_super().unsafe_get0(); - auto [update_header2, update_buf2] = *(cbj->read_super(0).unsafe_get0()); + cbj->write_header().unsafe_get0(); + auto [update_header2, update_buf2] = *(cbj->read_header(0).unsafe_get0()); ASSERT_EQ(header.used_size, update_header2.used_size); ASSERT_EQ(header.written_to + record_total_size, update_header2.written_to); -- 2.39.5