From 52bf8278121def862f32ad9e7d047f535f1af660 Mon Sep 17 00:00:00 2001 From: Myoungwon Oh Date: Thu, 16 Nov 2023 14:39:38 +0900 Subject: [PATCH] crimson/os/seastore: perform a inplace-partial-overwrite on the corresponding block using ool Signed-off-by: Myoungwon Oh --- src/crimson/os/seastore/cache.cc | 21 ++++++++++++++++++- src/crimson/os/seastore/cached_extent.h | 2 ++ .../os/seastore/extent_placement_manager.cc | 9 +++++++- src/crimson/os/seastore/object_data_handler.h | 4 ++++ src/crimson/os/seastore/transaction.h | 9 ++++++++ src/test/crimson/seastore/test_block.h | 4 ++++ 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 4d1dc929607..f0c7a0a34f2 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -1261,6 +1261,24 @@ record_t Cache::prepare_record( } } + for (auto &i: t.written_inplace_ool_block_list) { + if (!i->is_valid()) { + continue; + } + assert(i->state == CachedExtent::extent_state_t::DIRTY); + assert(i->version > 0); + remove_from_dirty(i); + // set the version to zero because the extent state is now clean + // in order to handle this transparently + i->version = 0; + i->dirty_from_or_retired_at = JOURNAL_SEQ_MIN; + i->state = CachedExtent::extent_state_t::CLEAN; + assert(i->is_logical()); + i->cast()->clear_delta(); + touch_extent(*i); + DEBUGT("inplace rewrite ool block is commmitted -- {}", t, *i); + } + for (auto &i: t.existing_block_list) { if (i->is_valid()) { alloc_delta.alloc_blk_ranges.emplace_back( @@ -1330,7 +1348,8 @@ record_t Cache::prepare_record( t.num_allocated_invalid_extents); auto& ool_stats = t.get_ool_write_stats(); - ceph_assert(ool_stats.extents.num == t.written_ool_block_list.size()); + ceph_assert(ool_stats.extents.num == t.written_ool_block_list.size() + + t.written_inplace_ool_block_list.size()); if (record.is_empty()) { SUBINFOT(seastore_t, diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index 8bd4a269385..18c102ed3e1 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -1242,6 +1242,8 @@ public: void on_replace_prior(Transaction &t) final; + virtual void clear_delta() {} + virtual ~LogicalCachedExtent(); protected: diff --git a/src/crimson/os/seastore/extent_placement_manager.cc b/src/crimson/os/seastore/extent_placement_manager.cc index b7aabefc644..f53b9f5be91 100644 --- a/src/crimson/os/seastore/extent_placement_manager.cc +++ b/src/crimson/os/seastore/extent_placement_manager.cc @@ -799,7 +799,14 @@ RandomBlockOolWriter::do_write( ).safe_then([&t, &ex, paddr, FNAME]() { TRACET("ool extent written at {} -- {}", t, paddr, *ex); - t.mark_allocated_extent_ool(ex); + if (ex->is_initial_pending()) { + t.mark_allocated_extent_ool(ex); + } else if (ex->is_dirty()) { + assert(t.get_src() == transaction_type_t::TRIM_DIRTY); + t.mark_inplace_rewrite_extent_ool(ex); + } else { + ceph_assert("impossible"); + } return alloc_write_iertr::now(); }); }); diff --git a/src/crimson/os/seastore/object_data_handler.h b/src/crimson/os/seastore/object_data_handler.h index eaa05da8d54..76d69eb73f9 100644 --- a/src/crimson/os/seastore/object_data_handler.h +++ b/src/crimson/os/seastore/object_data_handler.h @@ -60,6 +60,10 @@ struct ObjectDataBlock : crimson::os::seastore::LogicalCachedExtent { ceph::bufferlist get_delta() final; void apply_delta(const ceph::bufferlist &bl) final; + + void clear_delta() final { + delta.clear(); + } }; using ObjectDataBlockRef = TCachedExtentRef; diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index b43fb0d9cd8..a283982f699 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -217,6 +217,12 @@ public: written_ool_block_list.push_back(ref); } + void mark_inplace_rewrite_extent_ool(LogicalCachedExtentRef& ref) { + assert(ref->get_paddr().is_absolute()); + assert(!ref->is_inline()); + written_inplace_ool_block_list.push_back(ref); + } + void add_inplace_rewrite_extent(CachedExtentRef ref) { ceph_assert(!is_weak()); ceph_assert(ref); @@ -400,6 +406,7 @@ public: delayed_alloc_list.clear(); inline_block_list.clear(); written_ool_block_list.clear(); + written_inplace_ool_block_list.clear(); pre_alloc_list.clear(); pre_inplace_rewrite_list.clear(); retired_set.clear(); @@ -555,6 +562,8 @@ private: std::list inline_block_list; /// fresh blocks that will be committed with out-of-line record std::list written_ool_block_list; + /// dirty blocks that will be committed out-of-line with inplace rewrite + std::list written_inplace_ool_block_list; /// list of mutated blocks, holds refcounts, subset of write_set std::list mutated_block_list; diff --git a/src/test/crimson/seastore/test_block.h b/src/test/crimson/seastore/test_block.h index ccdafb7843f..bfb50670420 100644 --- a/src/test/crimson/seastore/test_block.h +++ b/src/test/crimson/seastore/test_block.h @@ -79,6 +79,10 @@ struct TestBlock : crimson::os::seastore::LogicalCachedExtent { } void apply_delta(const ceph::bufferlist &bl) final; + + void clear_delta() final { + delta.clear(); + } }; using TestBlockRef = TCachedExtentRef; -- 2.39.5