]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/hobject: define get_temp_pool() etc helpers
authorSage Weil <sage@redhat.com>
Fri, 14 Sep 2018 13:40:43 +0000 (08:40 -0500)
committerSage Weil <sage@redhat.com>
Fri, 14 Sep 2018 13:40:43 +0000 (08:40 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/hobject.h
src/osd/osd_types.h

index dc40dead4d2d65c9334997b2b6c9c8ea7870fe4d..2cea82ffbd2c3e88ab9365f050c443e4babe1330 100644 (file)
@@ -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) {
index 684828fcf16080cb2cfcba76afdbc80c75b2cc01..2ef28f886e599510ef15891a53804aed779100eb 100644 (file)
@@ -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);
   }