aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-01 19:00:15 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:17 -0400
commit41766f87f54cc8bef023b4b0550f48753959345a (patch)
tree58d11a1e3fcb0aef8d97b6cdc48bcf5811d32001
parentec02a2f2ffae13e038453ae89592a8c6210f7f4d (diff)
libceph: rename ceph_calc_object_layout()
The purpose of ceph_calc_object_layout() is to fill in the pool number and seed for a ceph_pg structure provided, based on a given osd map and target object id. Currently that function takes a file layout parameter, but the only thing used out of that is its pool number. Change the function so it takes a pool number rather than the full file layout structure. Only update the ceph_pg if the pool is found in the osd map. Get rid of few useless lines of code from the function while there. Since the function now very clearly just fills in the ceph_pg structure it's provided, rename it ceph_calc_ceph_pg(). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--fs/ceph/ioctl.c5
-rw-r--r--include/linux/ceph/osdmap.h6
-rw-r--r--net/ceph/osd_client.c4
-rw-r--r--net/ceph/osdmap.c23
4 files changed, 16 insertions, 22 deletions
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 4a989345b37b..e0b4ef31d3c8 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -208,8 +208,9 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
208 208
209 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx", 209 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
210 ceph_ino(inode), dl.object_no); 210 ceph_ino(inode), dl.object_no);
211 ceph_calc_object_layout(&pgid, dl.object_name, &ci->i_layout, 211
212 osdc->osdmap); 212 ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap,
213 ceph_file_layout_pg_pool(ci->i_layout));
213 214
214 dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid); 215 dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid);
215 if (dl.osd >= 0) { 216 if (dl.osd >= 0) {
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index c819190d1642..167daf60c4e8 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -131,10 +131,8 @@ extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
131 u64 *bno, u64 *oxoff, u64 *oxlen); 131 u64 *bno, u64 *oxoff, u64 *oxlen);
132 132
133/* calculate mapping of object to a placement group */ 133/* calculate mapping of object to a placement group */
134extern int ceph_calc_object_layout(struct ceph_pg *pg, 134extern int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
135 const char *oid, 135 struct ceph_osdmap *osdmap, uint64_t pool);
136 struct ceph_file_layout *fl,
137 struct ceph_osdmap *osdmap);
138extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, 136extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
139 struct ceph_pg pgid, 137 struct ceph_pg pgid,
140 int *acting); 138 int *acting);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d7ce457c59d9..38d09d13bb15 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -948,8 +948,8 @@ static int __map_request(struct ceph_osd_client *osdc,
948 int err; 948 int err;
949 949
950 dout("map_request %p tid %lld\n", req, req->r_tid); 950 dout("map_request %p tid %lld\n", req, req->r_tid);
951 err = ceph_calc_object_layout(&pgid, req->r_oid, 951 err = ceph_calc_ceph_pg(&pgid, req->r_oid, osdc->osdmap,
952 &req->r_file_layout, osdc->osdmap); 952 ceph_file_layout_pg_pool(req->r_file_layout));
953 if (err) { 953 if (err) {
954 list_move(&req->r_req_lru_item, &osdc->req_notarget); 954 list_move(&req->r_req_lru_item, &osdc->req_notarget);
955 return err; 955 return err;
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 4543b9aba40c..09898711f2fd 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1111,27 +1111,22 @@ EXPORT_SYMBOL(ceph_calc_file_object_mapping);
1111 * calculate an object layout (i.e. pgid) from an oid, 1111 * calculate an object layout (i.e. pgid) from an oid,
1112 * file_layout, and osdmap 1112 * file_layout, and osdmap
1113 */ 1113 */
1114int ceph_calc_object_layout(struct ceph_pg *pg, 1114int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
1115 const char *oid, 1115 struct ceph_osdmap *osdmap, uint64_t pool)
1116 struct ceph_file_layout *fl,
1117 struct ceph_osdmap *osdmap)
1118{ 1116{
1119 unsigned int num, num_mask; 1117 struct ceph_pg_pool_info *pool_info;
1120 struct ceph_pg_pool_info *pool;
1121 1118
1122 BUG_ON(!osdmap); 1119 BUG_ON(!osdmap);
1123 pg->pool = le32_to_cpu(fl->fl_pg_pool); 1120 pool_info = __lookup_pg_pool(&osdmap->pg_pools, pool);
1124 pool = __lookup_pg_pool(&osdmap->pg_pools, pg->pool); 1121 if (!pool_info)
1125 if (!pool)
1126 return -EIO; 1122 return -EIO;
1127 pg->seed = ceph_str_hash(pool->object_hash, oid, strlen(oid)); 1123 pg->pool = pool;
1128 num = pool->pg_num; 1124 pg->seed = ceph_str_hash(pool_info->object_hash, oid, strlen(oid));
1129 num_mask = pool->pg_num_mask;
1130 1125
1131 dout("calc_object_layout '%s' pgid %lld.%x\n", oid, pg->pool, pg->seed); 1126 dout("%s '%s' pgid %lld.%x\n", __func__, oid, pg->pool, pg->seed);
1132 return 0; 1127 return 0;
1133} 1128}
1134EXPORT_SYMBOL(ceph_calc_object_layout); 1129EXPORT_SYMBOL(ceph_calc_ceph_pg);
1135 1130
1136/* 1131/*
1137 * Calculate raw osd vector for the given pgid. Return pointer to osd 1132 * Calculate raw osd vector for the given pgid. Return pointer to osd