From cf4a4ebf2791b72958361e7a43918aaa590eb340 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 14 Sep 2018 08:40:43 -0500 Subject: [PATCH] common/hobject: define get_temp_pool() etc helpers Signed-off-by: Sage Weil --- src/common/hobject.h | 26 +++++++++++++++++++------- src/osd/osd_types.h | 7 ++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/common/hobject.h b/src/common/hobject.h index dc40dead4d2d6..2cea82ffbd2c3 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -35,6 +35,21 @@ namespace ceph { #endif struct hobject_t { +public: + static const int64_t POOL_META = -1; + static const int64_t POOL_TEMP_START = -2; // and then negative + + static bool is_temp_pool(int64_t pool) { + return pool <= POOL_TEMP_START; + } + static int64_t get_temp_pool(int64_t pool) { + return POOL_TEMP_START - pool; + } + static bool is_meta_pool(int64_t pool) { + return pool == POOL_META; + } + +public: object_t oid; snapid_t snap; private: @@ -42,10 +57,6 @@ private: bool max; uint32_t nibblewise_key_cache; uint32_t hash_reverse_bits; -public: - static const int64_t POOL_META = -1; - static const int64_t POOL_TEMP_START = -2; // and then negative - friend class spg_t; // for POOL_TEMP_START public: int64_t pool; string nspace; @@ -85,10 +96,10 @@ public: } bool is_temp() const { - return pool <= POOL_TEMP_START && pool != INT64_MIN; + return is_temp_pool(pool) && pool != INT64_MIN; } bool is_meta() const { - return pool == POOL_META; + return is_meta_pool(pool); } hobject_t() : snap(0), hash(0), max(false), pool(INT64_MIN) { @@ -259,7 +270,8 @@ public: hobject_t make_temp_hobject(const string& name) const { return hobject_t(object_t(name), "", CEPH_NOSNAP, hash, - hobject_t::POOL_TEMP_START - pool, ""); + get_temp_pool(pool), + ""); } void swap(hobject_t &o) { diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 684828fcf1608..2ef28f886e599 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -426,13 +426,13 @@ struct pg_t { bool contains(int bits, const ghobject_t& oid) { return ((int64_t)m_pool == oid.hobj.pool || - hobject_t::POOL_TEMP_START-(int64_t)m_pool == oid.hobj.pool) && + hobject_t::get_temp_pool(m_pool) == oid.hobj.pool) && oid.match(bits, ps()); } bool contains(int bits, const hobject_t& oid) { return ((int64_t)m_pool == oid.pool || - hobject_t::POOL_TEMP_START-(int64_t)m_pool == oid.pool) && + hobject_t::get_temp_pool(m_pool) == oid.pool) && oid.match(bits, ps()); } @@ -588,7 +588,8 @@ struct spg_t { return ghobject_t( hobject_t(object_t(name), "", CEPH_NOSNAP, pgid.ps(), - hobject_t::POOL_TEMP_START - pgid.pool(), ""), + hobject_t::get_temp_pool(pgid.pool()), + ""), ghobject_t::NO_GEN, shard); } -- 2.39.5