build_hash_cache();
}
+ // used by Crimson
+ hobject_t(const std::string &key, snapid_t snap, uint32_t reversed_hash,
+ int64_t pool, const std::string& nspace)
+ : oid(key), snap(snap), max(false), pool(pool), nspace(nspace) {
+ set_bitwise_key_u32(reversed_hash);
+ }
+
/// @return min hobject_t ret s.t. ret.hash == this->hash
hobject_t get_boundary() const {
if (is_max())
shard_id(shard),
max(false) {}
- ghobject_t(shard_id_t shard, int64_t pool, uint32_t hash,
+ // used by Crimson
+ ghobject_t(shard_id_t shard, int64_t pool, uint32_t reversed_hash,
const std::string& nspace, const std::string& oid,
snapid_t snap, gen_t gen)
- : hobj(object_t(oid), "", snap, hash, pool, nspace),
+ : hobj(oid, snap, reversed_hash, pool, nspace),
generation(gen),
shard_id(shard),
max(false) {}
using shard_t = int8_t;
using pool_t = int64_t;
+// Note: this is the reversed version of the object hash
using crush_hash_t = uint32_t;
using snap_t = uint64_t;
using gen_t = uint64_t;
static_assert(sizeof(shard_t) == sizeof(ghobject_t().shard_id.id));
static_assert(sizeof(pool_t) == sizeof(ghobject_t().hobj.pool));
-static_assert(sizeof(crush_hash_t) == sizeof(ghobject_t().hobj.get_hash()));
+static_assert(sizeof(crush_hash_t) == sizeof(ghobject_t().hobj.get_bitwise_key_u32()));
static_assert(sizeof(snap_t) == sizeof(ghobject_t().hobj.snap.val));
static_assert(sizeof(gen_t) == sizeof(ghobject_t().generation));
return toMatchKindCMP(l.pool, r.pool);
}
+// Note: this is the reversed version of the object hash
struct crush_t {
bool operator==(const crush_t& x) const { return crush == x.crush; }
bool operator!=(const crush_t& x) const { return !(*this == x); }
* ghobject_t::get_max() if necessary.
*/
inline const ghobject_t _MAX_OID() {
- return ghobject_t(shard_id_t(MAX_SHARD), MAX_POOL, MAX_CRUSH,
- "MAX", "MAX", MAX_SNAP, MAX_GEN);
+ auto ret = ghobject_t(shard_id_t(MAX_SHARD), MAX_POOL, MAX_CRUSH,
+ "MAX", "MAX", MAX_SNAP, MAX_GEN);
+ assert(ret.hobj.get_hash() == ret.hobj.get_bitwise_key_u32());
+ return ret;
}
// the valid key stored in tree should be in the range of (_MIN_OID, _MAX_OID)
return ghobj.hobj.pool;
}
crush_hash_t crush() const {
- return ghobj.hobj.get_hash();
+ // Note: this is the reversed version of the object hash
+ return ghobj.hobj.get_bitwise_key_u32();
}
laddr_t get_hint() const {
return get_lba_hint(shard(), pool(), crush());
ceph::decode(shard, delta);
pool_t pool;
ceph::decode(pool, delta);
+ // Note: this is the reversed version of the object hash
crush_hash_t crush;
ceph::decode(crush, delta);
std::string nspace;