From f6762a872b5f8314dd1c2fba3a5a4f0382bcfcb9 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Wed, 19 Mar 2025 10:44:59 +0800 Subject: [PATCH] crimson/os/seastore: improve is_logical() checks Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/cached_extent.h | 8 ++++---- src/crimson/os/seastore/transaction_manager.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index 0604982f7e871..1bed954713b04 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -403,6 +403,8 @@ public: virtual extent_types_t get_type() const = 0; virtual bool is_logical() const { + assert(!is_logical_type(get_type())); + assert(is_physical_type(get_type())); return false; } @@ -1349,10 +1351,6 @@ public: ceph_assert(0 == "Should never happen for a placeholder"); } - bool is_logical() const final { - return false; - } - void on_rewrite(Transaction &, CachedExtent&, extent_len_t) final {} std::ostream &print_detail(std::ostream &out) const final { @@ -1406,6 +1404,8 @@ public: } bool is_logical() const final { + assert(is_logical_type(get_type())); + assert(!is_physical_type(get_type())); return true; } diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index fc7137dfe5186..5bb06b4d02a79 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -1043,6 +1043,7 @@ private: partial_len, [&pref] (T &extent) mutable { + assert(extent.is_logical()); assert(!extent.has_laddr()); assert(!extent.has_been_invalidated()); assert(!pref.has_been_invalidated()); @@ -1118,6 +1119,7 @@ private: direct_key, direct_length, [&pref](CachedExtent &extent) mutable { + assert(extent.is_logical()); auto &lextent = static_cast(extent); assert(!lextent.has_laddr()); assert(!lextent.has_been_invalidated()); -- 2.39.5