return 0;
}
-static string make_hash_str(const string &inkey, const string &nspace)
-{
- if (nspace.empty())
- return inkey;
- return nspace + '\037' + inkey;
-}
-
// mapping
int OSDMap::object_locator_to_pg(
const object_t& oid,
if (loc.hash >= 0) {
ps = loc.hash;
} else {
- string key;
if (!loc.key.empty())
- key = make_hash_str(loc.key, loc.nspace);
+ ps = pool->hash_key(loc.key, loc.nspace);
else
- key = make_hash_str(oid.name, loc.nspace);
-
- ps = ceph_str_hash(pool->object_hash, key.c_str(), key.length());
+ ps = pool->hash_key(oid.name, loc.nspace);
}
pg = pg_t(ps, loc.get_pool(), -1);
return 0;
return SnapContext(get_snap_seq(), s);
}
+static string make_hash_str(const string &inkey, const string &nspace)
+{
+ if (nspace.empty())
+ return inkey;
+ return nspace + '\037' + inkey;
+}
+
+uint32_t pg_pool_t::hash_key(const string& key, const string& ns) const
+{
+ string n = make_hash_str(key, ns);
+ return ceph_str_hash(object_hash, n.c_str(), n.length());
+}
+
+uint32_t pg_pool_t::raw_hash_to_pg(uint32_t v) const
+{
+ return ceph_stable_mod(v, pg_num, pg_num_mask);
+}
+
/*
* map a raw pg (with full precision ps) into an actual pg, for storage
*/
SnapContext get_snap_context() const;
+ /// hash a object name+namespace key to a hash position
+ uint32_t hash_key(const string& key, const string& ns) const;
+
+ /// round a hash position down to a pg num
+ uint32_t raw_hash_to_pg(uint32_t v) const;
+
/*
* map a raw pg (with full precision ps) into an actual pg, for storage
*/