};
}
-typedef uint32_t filestore_hobject_key_t;
+typedef uint64_t filestore_hobject_key_t;
struct hobject_t {
object_t oid;
snapid_t snap;
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);
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) {
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