mirror of
https://github.com/ceph/ceph
synced 2024-12-22 03:22:00 +00:00
osd/OSDMap: generalize map_to_pg
So we can do this without constructing an object_locator_t. Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
0efdd0a338
commit
a6fa7b6568
@ -1484,28 +1484,39 @@ int OSDMap::apply_incremental(const Incremental &inc)
|
||||
}
|
||||
|
||||
// mapping
|
||||
int OSDMap::object_locator_to_pg(
|
||||
const object_t& oid,
|
||||
const object_locator_t& loc,
|
||||
pg_t &pg) const
|
||||
int OSDMap::map_to_pg(
|
||||
int64_t poolid,
|
||||
const string& name,
|
||||
const string& key,
|
||||
const string& nspace,
|
||||
pg_t *pg) const
|
||||
{
|
||||
// calculate ps (placement seed)
|
||||
const pg_pool_t *pool = get_pg_pool(loc.get_pool());
|
||||
const pg_pool_t *pool = get_pg_pool(poolid);
|
||||
if (!pool)
|
||||
return -ENOENT;
|
||||
ps_t ps;
|
||||
if (loc.hash >= 0) {
|
||||
ps = loc.hash;
|
||||
} else {
|
||||
if (!loc.key.empty())
|
||||
ps = pool->hash_key(loc.key, loc.nspace);
|
||||
else
|
||||
ps = pool->hash_key(oid.name, loc.nspace);
|
||||
}
|
||||
pg = pg_t(ps, loc.get_pool(), -1);
|
||||
if (!key.empty())
|
||||
ps = pool->hash_key(key, nspace);
|
||||
else
|
||||
ps = pool->hash_key(name, nspace);
|
||||
*pg = pg_t(ps, poolid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OSDMap::object_locator_to_pg(
|
||||
const object_t& oid, const object_locator_t& loc, pg_t &pg) const
|
||||
{
|
||||
if (loc.hash >= 0) {
|
||||
if (!get_pg_pool(loc.get_pool())) {
|
||||
return -ENOENT;
|
||||
}
|
||||
pg = pg_t(loc.hash, loc.get_pool());
|
||||
return 0;
|
||||
}
|
||||
return map_to_pg(loc.get_pool(), oid.name, loc.key, loc.nspace, &pg);
|
||||
}
|
||||
|
||||
ceph_object_layout OSDMap::make_object_layout(
|
||||
object_t oid, int pg_pool, string nspace) const
|
||||
{
|
||||
|
@ -587,14 +587,23 @@ public:
|
||||
|
||||
|
||||
/**** mapping facilities ****/
|
||||
int object_locator_to_pg(const object_t& oid, const object_locator_t& loc, pg_t &pg) const;
|
||||
pg_t object_locator_to_pg(const object_t& oid, const object_locator_t& loc) const {
|
||||
int map_to_pg(
|
||||
int64_t pool,
|
||||
const string& name,
|
||||
const string& key,
|
||||
const string& nspace,
|
||||
pg_t *pg) const;
|
||||
int object_locator_to_pg(const object_t& oid, const object_locator_t& loc,
|
||||
pg_t &pg) const;
|
||||
pg_t object_locator_to_pg(const object_t& oid,
|
||||
const object_locator_t& loc) const {
|
||||
pg_t pg;
|
||||
int ret = object_locator_to_pg(oid, loc, pg);
|
||||
assert(ret == 0);
|
||||
return pg;
|
||||
}
|
||||
|
||||
|
||||
static object_locator_t file_to_object_locator(const file_layout_t& layout) {
|
||||
return object_locator_t(layout.pool_id, layout.pool_ns);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user