From 97dcfbaed6bc2bc7edafd76880ec03ebcf141386 Mon Sep 17 00:00:00 2001 From: Zhang Song Date: Mon, 13 Jun 2022 10:37:52 +0800 Subject: [PATCH] crimson/os/seastore: new extent state: EXIST_CLEAN and EXIST_MUTATION_PENDING Signed-off-by: Zhang Song --- src/crimson/os/seastore/cached_extent.cc | 4 +++ src/crimson/os/seastore/cached_extent.h | 34 +++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/crimson/os/seastore/cached_extent.cc b/src/crimson/os/seastore/cached_extent.cc index a4f7423f5f3..dc7b8e6165b 100644 --- a/src/crimson/os/seastore/cached_extent.cc +++ b/src/crimson/os/seastore/cached_extent.cc @@ -54,6 +54,10 @@ std::ostream &operator<<(std::ostream &out, CachedExtent::extent_state_t state) return out << "CLEAN"; case CachedExtent::extent_state_t::DIRTY: return out << "DIRTY"; + case CachedExtent::extent_state_t::EXIST_CLEAN: + return out << "EXIST_CLEAN"; + case CachedExtent::extent_state_t::EXIST_MUTATION_PENDING: + return out << "EXIST_MUTATION_PENDING"; case CachedExtent::extent_state_t::INVALID: return out << "INVALID"; default: diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index 91e0d0ad915..83f223f5d42 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -88,6 +88,17 @@ class CachedExtent : public boost::intrusive_ref_counter< // during write, contents match disk, version == 0 DIRTY, // Same as CLEAN, but contents do not match disk, // version > 0 + EXIST_CLEAN, // Similar to CLEAN, but its metadata not yet + // persisted to disk. + // In Transaction::write_set and existing_block_list. + // After transaction commits, state becomes CLEAN + // and add extent to Cache. Modifing such extents + // will cause state turn to EXIST_MUTATION_PENDING. + EXIST_MUTATION_PENDING,// Similar to MUTATION_PENDING, but its prior_instance + // is empty. + // In Transaction::write_set, existing_block_list and + // mutated_block_list. State becomes DIRTY and it is + // added to Cache after transaction commits. INVALID // Part of no ExtentIndex set } state = extent_state_t::INVALID; friend std::ostream &operator<<(std::ostream &, extent_state_t); @@ -268,7 +279,8 @@ public: /// Returns true if extent is part of an open transaction bool is_pending() const { return state == extent_state_t::INITIAL_WRITE_PENDING || - state == extent_state_t::MUTATION_PENDING; + state == extent_state_t::MUTATION_PENDING || + state == extent_state_t::EXIST_MUTATION_PENDING; } /// Returns true if extent has a pending delta @@ -286,7 +298,18 @@ public: ceph_assert(is_valid()); return state == extent_state_t::INITIAL_WRITE_PENDING || state == extent_state_t::CLEAN || - state == extent_state_t::CLEAN_PENDING; + state == extent_state_t::CLEAN_PENDING || + state == extent_state_t::EXIST_CLEAN; + } + + /// Ruturns true if data is persisted while metadata isn't + bool is_exist_clean() const { + return state == extent_state_t::EXIST_CLEAN; + } + + /// Returns true if the extent with EXTIST_CLEAN is modified + bool is_exist_mutation_pending() const { + return state == extent_state_t::EXIST_MUTATION_PENDING; } /// Returns true if extent is dirty (has deltas on disk) @@ -838,8 +861,11 @@ protected: virtual void logical_on_delta_write() {} void on_delta_write(paddr_t record_block_offset) final { - assert(get_prior_instance()); - pin->take_pin(*(get_prior_instance()->cast()->pin)); + assert(is_exist_mutation_pending() || + get_prior_instance()); + if (get_prior_instance()) { + pin->take_pin(*(get_prior_instance()->cast()->pin)); + } logical_on_delta_write(); } -- 2.39.5