aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 10:40:19 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 16:57:32 -0500
commit7c13cb64352230deac24d3cb058387a6c0676f83 (patch)
tree136efed002c9fbbdf97bfe9a666fb1c1cc244e8c
parent4295f2217a5aa8ef2738e3a368db3c1ceab41212 (diff)
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: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
-rw-r--r--fs/ceph/ioctl.c8
-rw-r--r--include/linux/ceph/osdmap.h7
-rw-r--r--net/ceph/osd_client.c4
-rw-r--r--net/ceph/osdmap.c29
4 files changed, 30 insertions, 18 deletions
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 669622fd1ae3..dc66c9e023e4 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -183,6 +183,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
183 struct ceph_inode_info *ci = ceph_inode(inode); 183 struct ceph_inode_info *ci = ceph_inode(inode);
184 struct ceph_osd_client *osdc = 184 struct ceph_osd_client *osdc =
185 &ceph_sb_to_client(inode->i_sb)->client->osdc; 185 &ceph_sb_to_client(inode->i_sb)->client->osdc;
186 struct ceph_object_locator oloc;
187 struct ceph_object_id oid;
186 u64 len = 1, olen; 188 u64 len = 1, olen;
187 u64 tmp; 189 u64 tmp;
188 struct ceph_pg pgid; 190 struct ceph_pg pgid;
@@ -211,8 +213,10 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
211 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx", 213 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
212 ceph_ino(inode), dl.object_no); 214 ceph_ino(inode), dl.object_no);
213 215
214 r = ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap, 216 oloc.pool = ceph_file_layout_pg_pool(ci->i_layout);
215 ceph_file_layout_pg_pool(ci->i_layout)); 217 ceph_oid_set_name(&oid, dl.object_name);
218
219 r = ceph_oloc_oid_to_pg(osdc->osdmap, &oloc, &oid, &pgid);
216 if (r < 0) { 220 if (r < 0) {
217 up_read(&osdc->map_sem); 221 up_read(&osdc->map_sem);
218 return r; 222 return r;
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index c85f7d43b861..ebb8ec285de6 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -163,8 +163,11 @@ extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
163 u64 *bno, u64 *oxoff, u64 *oxlen); 163 u64 *bno, u64 *oxoff, u64 *oxlen);
164 164
165/* calculate mapping of object to a placement group */ 165/* calculate mapping of object to a placement group */
166extern int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid, 166extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
167 struct ceph_osdmap *osdmap, uint64_t pool); 167 struct ceph_object_locator *oloc,
168 struct ceph_object_id *oid,
169 struct ceph_pg *pg_out);
170
168extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, 171extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
169 struct ceph_pg pgid, 172 struct ceph_pg pgid,
170 int *acting); 173 int *acting);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 2988d68b24c6..10360dedcdad 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1269,8 +1269,8 @@ static int __map_request(struct ceph_osd_client *osdc,
1269 bool was_paused; 1269 bool was_paused;
1270 1270
1271 dout("map_request %p tid %lld\n", req, req->r_tid); 1271 dout("map_request %p tid %lld\n", req, req->r_tid);
1272 err = ceph_calc_ceph_pg(&pgid, req->r_oid.name, osdc->osdmap, 1272 err = ceph_oloc_oid_to_pg(osdc->osdmap, &req->r_oloc, &req->r_oid,
1273 req->r_oloc.pool); 1273 &pgid);
1274 if (err) { 1274 if (err) {
1275 list_move(&req->r_req_lru_item, &osdc->req_notarget); 1275 list_move(&req->r_req_lru_item, &osdc->req_notarget);
1276 return err; 1276 return err;
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 8b1a6b48bb5d..768dd04eb9b1 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1090,25 +1090,30 @@ invalid:
1090EXPORT_SYMBOL(ceph_calc_file_object_mapping); 1090EXPORT_SYMBOL(ceph_calc_file_object_mapping);
1091 1091
1092/* 1092/*
1093 * calculate an object layout (i.e. pgid) from an oid, 1093 * Calculate mapping of a (oloc, oid) pair to a PG. Should only be
1094 * file_layout, and osdmap 1094 * called with target's (oloc, oid), since tiering isn't taken into
1095 * account.
1095 */ 1096 */
1096int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid, 1097int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
1097 struct ceph_osdmap *osdmap, uint64_t pool) 1098 struct ceph_object_locator *oloc,
1099 struct ceph_object_id *oid,
1100 struct ceph_pg *pg_out)
1098{ 1101{
1099 struct ceph_pg_pool_info *pool_info; 1102 struct ceph_pg_pool_info *pi;
1100 1103
1101 BUG_ON(!osdmap); 1104 pi = __lookup_pg_pool(&osdmap->pg_pools, oloc->pool);
1102 pool_info = __lookup_pg_pool(&osdmap->pg_pools, pool); 1105 if (!pi)
1103 if (!pool_info)
1104 return -EIO; 1106 return -EIO;
1105 pg->pool = pool;
1106 pg->seed = ceph_str_hash(pool_info->object_hash, oid, strlen(oid));
1107 1107
1108 dout("%s '%s' pgid %lld.%x\n", __func__, oid, pg->pool, pg->seed); 1108 pg_out->pool = oloc->pool;
1109 pg_out->seed = ceph_str_hash(pi->object_hash, oid->name,
1110 oid->name_len);
1111
1112 dout("%s '%.*s' pgid %llu.%x\n", __func__, oid->name_len, oid->name,
1113 pg_out->pool, pg_out->seed);
1109 return 0; 1114 return 0;
1110} 1115}
1111EXPORT_SYMBOL(ceph_calc_ceph_pg); 1116EXPORT_SYMBOL(ceph_oloc_oid_to_pg);
1112 1117
1113static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x, 1118static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x,
1114 int *result, int result_max, 1119 int *result, int result_max,