From 4daf99778bdf8c23ce628f7b8d4feb6badbc212c Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Fri, 5 Aug 2022 10:20:06 +0800 Subject: [PATCH] crimson/os/seastore: introduce P_ADDR_ROOT Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/cache.cc | 2 +- src/crimson/os/seastore/seastore_types.cc | 2 ++ src/crimson/os/seastore/seastore_types.h | 13 ++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index d4670e8431f..5ae8a5205e1 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -1580,7 +1580,7 @@ void Cache::init() } root = new RootBlock(); root->init(CachedExtent::extent_state_t::CLEAN, - P_ADDR_NULL, + P_ADDR_ROOT, PLACEMENT_HINT_NULL, NULL_GENERATION); INFO("init root -- {}", *root); diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc index 3134fe3a040..b97630cd9b9 100644 --- a/src/crimson/os/seastore/seastore_types.cc +++ b/src/crimson/os/seastore/seastore_types.cc @@ -48,6 +48,8 @@ std::ostream &operator<<(std::ostream &out, const device_id_printer_t &id) return out << "Dev(FAKE)"; } else if (_id == DEVICE_ID_ZERO) { return out << "Dev(ZERO)"; + } else if (_id == DEVICE_ID_ROOT) { + return out << "Dev(ROOT)"; } else { return out << "Dev(" << (unsigned)_id << ")"; } diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index e305ac533bb..07b13269c68 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -64,7 +64,8 @@ constexpr device_id_t DEVICE_ID_DELAYED = DEVICE_ID_MAX - 3; // for tests which generate fake paddrs constexpr device_id_t DEVICE_ID_FAKE = DEVICE_ID_MAX - 4; constexpr device_id_t DEVICE_ID_ZERO = DEVICE_ID_MAX - 5; -constexpr device_id_t DEVICE_ID_MAX_VALID = DEVICE_ID_MAX - 6; +constexpr device_id_t DEVICE_ID_ROOT = DEVICE_ID_MAX - 6; +constexpr device_id_t DEVICE_ID_MAX_VALID = DEVICE_ID_MAX - 7; constexpr device_id_t DEVICE_ID_MAX_VALID_SEGMENT = DEVICE_ID_MAX >> 1; struct device_id_printer_t { @@ -94,7 +95,8 @@ constexpr bool has_seastore_off(device_id_t id) { return id == DEVICE_ID_RECORD_RELATIVE || id == DEVICE_ID_BLOCK_RELATIVE || id == DEVICE_ID_DELAYED || - id == DEVICE_ID_FAKE; + id == DEVICE_ID_FAKE || + id == DEVICE_ID_ROOT; } // internal segment id type of segment_id_t below, with the top @@ -578,6 +580,10 @@ public: bool is_zero() const { return get_device_id() == DEVICE_ID_ZERO; } + /// Denotes the root addr + bool is_root() const { + return get_device_id() == DEVICE_ID_ROOT; + } /** * is_real @@ -587,7 +593,7 @@ public: * which unit tests use them. */ bool is_real() const { - return !is_zero() && !is_null(); + return !is_zero() && !is_null() && !is_root(); } bool is_absolute() const { @@ -731,6 +737,7 @@ constexpr paddr_t P_ADDR_MIN = paddr_t::create_const(0, 0, 0); constexpr paddr_t P_ADDR_MAX = paddr_t::create_const(DEVICE_ID_MAX, 0, 0); constexpr paddr_t P_ADDR_NULL = P_ADDR_MAX; constexpr paddr_t P_ADDR_ZERO = paddr_t::create_const(DEVICE_ID_ZERO, 0, 0); +constexpr paddr_t P_ADDR_ROOT = paddr_t::create_const(DEVICE_ID_ROOT, 0, 0); inline paddr_t make_record_relative_paddr(seastore_off_t off) { return paddr_t::make_res_paddr(DEVICE_ID_RECORD_RELATIVE, off); -- 2.39.5