]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hobject_t: make filestore_hobject_key_t 64 bits
authorSage Weil <sage.weil@dreamhost.com>
Thu, 1 Dec 2011 21:12:43 +0000 (13:12 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Wed, 7 Dec 2011 19:40:11 +0000 (11:40 -0800)
So we can return 0x100000000 when max=true.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/object.h
src/os/HashIndex.cc

index 1fbea7816ae4817e540c45066a04d40121929245..ed20ecc5292a09e826b5ce1ffb388949f2fbefc3 100644 (file)
@@ -259,7 +259,7 @@ namespace __gnu_cxx {
   };
 }
 
-typedef uint32_t filestore_hobject_key_t;
+typedef uint64_t filestore_hobject_key_t;
 struct hobject_t {
   object_t oid;
   snapid_t snap;
@@ -293,8 +293,7 @@ public:
     return max;
   }
 
-  filestore_hobject_key_t get_filestore_key() const {
-    uint32_t retval = hash;
+  static uint32_t _reverse_nibbles(uint32_t retval) {
     // reverse nibbles
     retval = ((retval & 0x0f0f0f0f) << 4) | ((retval & 0xf0f0f0f0) >> 4);
     retval = ((retval & 0x00ff00ff) << 8) | ((retval & 0xff00ff00) >> 8);
@@ -302,6 +301,16 @@ public:
     return retval;
   }
 
+  filestore_hobject_key_t get_filestore_key() const {
+    if (max)
+      return 0x100000000ull;
+    else
+      return _reverse_nibbles(hash);
+  }
+  void set_filestore_key(uint32_t v) {
+    hash = _reverse_nibbles(v);
+  }
+
   /* Do not use when a particular hash function is needed */
   explicit hobject_t(const sobject_t &o) :
     oid(o.oid), snap(o.snap) {
index cf83e58541c97d9b4c7d5eb5d6a3277c7e3adefd..1442ea28358d689270d7e25e65bf6dc4e22d0151 100644 (file)
@@ -385,7 +385,7 @@ int HashIndex::complete_split(const vector<string> &path, subdir_info_s info) {
 void HashIndex::get_path_components(const hobject_t &hoid,
                                    vector<string> *path) {
   char buf[MAX_HASH_LEVEL + 1];
-  snprintf(buf, sizeof(buf), "%.*X", MAX_HASH_LEVEL, hoid.get_filestore_key());
+  snprintf(buf, sizeof(buf), "%.*X", MAX_HASH_LEVEL, (uint32_t)hoid.get_filestore_key());
 
   // Path components are the hex characters of hoid.hash, least
   // significant first