From 6e583ccf458c740d6da86a19722b3e484aaf285c Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Thu, 9 May 2024 20:01:29 +0800 Subject: [PATCH] crimson/os/seastore/cache: add retire_absent_extent_addr() interface Signed-off-by: Xuehan Xu --- src/crimson/os/seastore/cache.cc | 27 +++++++++++++++++++++++++++ src/crimson/os/seastore/cache.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 801ba356fbe4f..bfe002bb2a509 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -104,6 +104,33 @@ Cache::retire_extent_ret Cache::retire_extent_addr( return retire_extent_iertr::now(); } +void Cache::retire_absent_extent_addr( + Transaction &t, paddr_t addr, extent_len_t length) +{ +#ifndef NDEBUG + CachedExtentRef ext; + auto result = t.get_extent(addr, &ext); + assert(result != Transaction::get_extent_ret::PRESENT + && result != Transaction::get_extent_ret::RETIRED); + assert(!query_cache(addr, nullptr)); +#endif + LOG_PREFIX(Cache::retire_absent_extent_addr); + // add a new placeholder to Cache + ext = CachedExtent::make_cached_extent_ref< + RetiredExtentPlaceholder>(length); + ext->init(CachedExtent::extent_state_t::CLEAN, + addr, + PLACEMENT_HINT_NULL, + NULL_GENERATION, + TRANS_ID_NULL); + DEBUGT("retire {}~{} as placeholder, add extent -- {}", + t, addr, length, *ext); + const auto t_src = t.get_src(); + add_extent(ext, &t_src); + t.add_to_read_set(ext); + t.add_to_retired_set(ext); +} + void Cache::dump_contents() { LOG_PREFIX(Cache::dump_contents); diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index 0bf03abf6a909..fb7f44b4ee1c1 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -246,6 +246,9 @@ public: retire_extent_ret retire_extent_addr( Transaction &t, paddr_t addr, extent_len_t length); + void retire_absent_extent_addr( + Transaction &t, paddr_t addr, extent_len_t length); + /** * get_root * -- 2.39.5