Commit 7c13cb64 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: replace ceph_calc_ceph_pg() with ceph_oloc_oid_to_pg()

Switch ceph_calc_ceph_pg() to new oloc and oid abstractions and rename
it to ceph_oloc_oid_to_pg() to make its purpose more clear.
Signed-off-by: default avatarIlya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent 4295f221
...@@ -183,6 +183,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) ...@@ -183,6 +183,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_osd_client *osdc = struct ceph_osd_client *osdc =
&ceph_sb_to_client(inode->i_sb)->client->osdc; &ceph_sb_to_client(inode->i_sb)->client->osdc;
struct ceph_object_locator oloc;
struct ceph_object_id oid;
u64 len = 1, olen; u64 len = 1, olen;
u64 tmp; u64 tmp;
struct ceph_pg pgid; struct ceph_pg pgid;
...@@ -211,8 +213,10 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) ...@@ -211,8 +213,10 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx", snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
ceph_ino(inode), dl.object_no); ceph_ino(inode), dl.object_no);
r = ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap, oloc.pool = ceph_file_layout_pg_pool(ci->i_layout);
ceph_file_layout_pg_pool(ci->i_layout)); ceph_oid_set_name(&oid, dl.object_name);
r = ceph_oloc_oid_to_pg(osdc->osdmap, &oloc, &oid, &pgid);
if (r < 0) { if (r < 0) {
up_read(&osdc->map_sem); up_read(&osdc->map_sem);
return r; return r;
......
...@@ -163,8 +163,11 @@ extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, ...@@ -163,8 +163,11 @@ extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
u64 *bno, u64 *oxoff, u64 *oxlen); u64 *bno, u64 *oxoff, u64 *oxlen);
/* calculate mapping of object to a placement group */ /* calculate mapping of object to a placement group */
extern int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid, extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
struct ceph_osdmap *osdmap, uint64_t pool); struct ceph_object_locator *oloc,
struct ceph_object_id *oid,
struct ceph_pg *pg_out);
extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
struct ceph_pg pgid, struct ceph_pg pgid,
int *acting); int *acting);
......
...@@ -1269,8 +1269,8 @@ static int __map_request(struct ceph_osd_client *osdc, ...@@ -1269,8 +1269,8 @@ static int __map_request(struct ceph_osd_client *osdc,
bool was_paused; bool was_paused;
dout("map_request %p tid %lld\n", req, req->r_tid); dout("map_request %p tid %lld\n", req, req->r_tid);
err = ceph_calc_ceph_pg(&pgid, req->r_oid.name, osdc->osdmap, err = ceph_oloc_oid_to_pg(osdc->osdmap, &req->r_oloc, &req->r_oid,
req->r_oloc.pool); &pgid);
if (err) { if (err) {
list_move(&req->r_req_lru_item, &osdc->req_notarget); list_move(&req->r_req_lru_item, &osdc->req_notarget);
return err; return err;
......
...@@ -1090,25 +1090,30 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, ...@@ -1090,25 +1090,30 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
EXPORT_SYMBOL(ceph_calc_file_object_mapping); EXPORT_SYMBOL(ceph_calc_file_object_mapping);
/* /*
* calculate an object layout (i.e. pgid) from an oid, * Calculate mapping of a (oloc, oid) pair to a PG. Should only be
* file_layout, and osdmap * called with target's (oloc, oid), since tiering isn't taken into
* account.
*/ */
int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid, int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
struct ceph_osdmap *osdmap, uint64_t pool) struct ceph_object_locator *oloc,
struct ceph_object_id *oid,
struct ceph_pg *pg_out)
{ {
struct ceph_pg_pool_info *pool_info; struct ceph_pg_pool_info *pi;
BUG_ON(!osdmap); pi = __lookup_pg_pool(&osdmap->pg_pools, oloc->pool);
pool_info = __lookup_pg_pool(&osdmap->pg_pools, pool); if (!pi)
if (!pool_info)
return -EIO; return -EIO;
pg->pool = pool;
pg->seed = ceph_str_hash(pool_info->object_hash, oid, strlen(oid));
dout("%s '%s' pgid %lld.%x\n", __func__, oid, pg->pool, pg->seed); pg_out->pool = oloc->pool;
pg_out->seed = ceph_str_hash(pi->object_hash, oid->name,
oid->name_len);
dout("%s '%.*s' pgid %llu.%x\n", __func__, oid->name_len, oid->name,
pg_out->pool, pg_out->seed);
return 0; return 0;
} }
EXPORT_SYMBOL(ceph_calc_ceph_pg); EXPORT_SYMBOL(ceph_oloc_oid_to_pg);
static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x, static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x,
int *result, int result_max, int *result, int result_max,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment