]> 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)
committerPrashant D <pdhange@redhat.com>
Mon, 8 Oct 2018 21:36:52 +0000 (17:36 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit cf4a4ebf2791b72958361e7a43918aaa590eb340)

src/common/hobject.h
src/osd/osd_types.h

index d05d294abe19bc671a564b206de5d69cd659aebb..c84bd25b5b3c110fad20f16c42f41cee2145f5d6 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 95dbab04553e46422487677ebcf15782a7f7e370..a7891c631085bd5eb8e8092207af3c43bc41dc9a 100644 (file)
@@ -421,13 +421,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());
   }
 
@@ -570,7 +570,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);
   }