From 0807e7d523441110eca23e27c90cc262afec859c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 1 Dec 2011 13:12:43 -0800 Subject: [PATCH] hobject_t: make filestore_hobject_key_t 64 bits So we can return 0x100000000 when max=true. Signed-off-by: Sage Weil --- src/include/object.h | 15 ++++++++++++--- src/os/HashIndex.cc | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/include/object.h b/src/include/object.h index 1fbea7816ae48..ed20ecc5292a0 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -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) { diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc index cf83e58541c97..1442ea28358d6 100644 --- a/src/os/HashIndex.cc +++ b/src/os/HashIndex.cc @@ -385,7 +385,7 @@ int HashIndex::complete_split(const vector &path, subdir_info_s info) { void HashIndex::get_path_components(const hobject_t &hoid, vector *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 -- 2.39.5