aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-02-25 19:13:08 -0500
committerSage Weil <sage@inktank.com>2013-02-26 18:02:37 -0500
commit2169aea649c08374bec7d220a3b8f64712275356 (patch)
tree8a287c8239a5e1fc47afae4fbec530a467825706 /net/ceph
parent4f6a7e5ee1393ec4b243b39dac9f36992d161540 (diff)
libceph: calculate placement based on the internal data types
Instead of using the old ceph_object_layout struct, update our internal ceph_calc_object_layout method to use the ceph_pg type. This allows us to pass the full 32-bit precision of the pgid.seed to the callers. It also allows some callers to avoid reaching into the request structures for the struct ceph_object_layout fields. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osd_client.c11
-rw-r--r--net/ceph/osdmap.c18
2 files changed, 12 insertions, 17 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1990834e518b..5584f0a08e28 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -913,21 +913,18 @@ EXPORT_SYMBOL(ceph_osdc_set_request_linger);
913static int __map_request(struct ceph_osd_client *osdc, 913static int __map_request(struct ceph_osd_client *osdc,
914 struct ceph_osd_request *req, int force_resend) 914 struct ceph_osd_request *req, int force_resend)
915{ 915{
916 struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base;
917 struct ceph_pg pgid; 916 struct ceph_pg pgid;
918 int acting[CEPH_PG_MAX_SIZE]; 917 int acting[CEPH_PG_MAX_SIZE];
919 int o = -1, num = 0; 918 int o = -1, num = 0;
920 int err; 919 int err;
921 920
922 dout("map_request %p tid %lld\n", req, req->r_tid); 921 dout("map_request %p tid %lld\n", req, req->r_tid);
923 err = ceph_calc_object_layout(&reqhead->layout, req->r_oid, 922 err = ceph_calc_object_layout(&pgid, req->r_oid,
924 &req->r_file_layout, osdc->osdmap); 923 &req->r_file_layout, osdc->osdmap);
925 if (err) { 924 if (err) {
926 list_move(&req->r_req_lru_item, &osdc->req_notarget); 925 list_move(&req->r_req_lru_item, &osdc->req_notarget);
927 return err; 926 return err;
928 } 927 }
929 pgid.pool = le32_to_cpu(reqhead->layout.ol_pgid.pool);
930 pgid.seed = le16_to_cpu(reqhead->layout.ol_pgid.ps);
931 req->r_pgid = pgid; 928 req->r_pgid = pgid;
932 929
933 err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting); 930 err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting);
@@ -1000,10 +997,16 @@ static void __send_request(struct ceph_osd_client *osdc,
1000 req, req->r_tid, req->r_osd->o_osd, req->r_flags); 997 req, req->r_tid, req->r_osd->o_osd, req->r_flags);
1001 998
1002 reqhead = req->r_request->front.iov_base; 999 reqhead = req->r_request->front.iov_base;
1000 reqhead->snapid = cpu_to_le64(req->r_snapid);
1003 reqhead->osdmap_epoch = cpu_to_le32(osdc->osdmap->epoch); 1001 reqhead->osdmap_epoch = cpu_to_le32(osdc->osdmap->epoch);
1004 reqhead->flags |= cpu_to_le32(req->r_flags); /* e.g., RETRY */ 1002 reqhead->flags |= cpu_to_le32(req->r_flags); /* e.g., RETRY */
1005 reqhead->reassert_version = req->r_reassert_version; 1003 reqhead->reassert_version = req->r_reassert_version;
1006 1004
1005 reqhead->layout.ol_pgid.ps = cpu_to_le16(req->r_pgid.seed);
1006 reqhead->layout.ol_pgid.pool = cpu_to_le32(req->r_pgid.pool);
1007 reqhead->layout.ol_pgid.preferred = cpu_to_le16(-1);
1008 reqhead->layout.ol_stripe_unit = 0;
1009
1007 req->r_stamp = jiffies; 1010 req->r_stamp = jiffies;
1008 list_move_tail(&req->r_req_lru_item, &osdc->req_lru); 1011 list_move_tail(&req->r_req_lru_item, &osdc->req_lru);
1009 1012
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 911919320d2e..378471644501 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1095,32 +1095,24 @@ EXPORT_SYMBOL(ceph_calc_file_object_mapping);
1095 * calculate an object layout (i.e. pgid) from an oid, 1095 * calculate an object layout (i.e. pgid) from an oid,
1096 * file_layout, and osdmap 1096 * file_layout, and osdmap
1097 */ 1097 */
1098int ceph_calc_object_layout(struct ceph_object_layout *ol, 1098int ceph_calc_object_layout(struct ceph_pg *pg,
1099 const char *oid, 1099 const char *oid,
1100 struct ceph_file_layout *fl, 1100 struct ceph_file_layout *fl,
1101 struct ceph_osdmap *osdmap) 1101 struct ceph_osdmap *osdmap)
1102{ 1102{
1103 unsigned int num, num_mask; 1103 unsigned int num, num_mask;
1104 struct ceph_pg pgid;
1105 struct ceph_pg_pool_info *pool; 1104 struct ceph_pg_pool_info *pool;
1106 1105
1107 BUG_ON(!osdmap); 1106 BUG_ON(!osdmap);
1108 1107 pg->pool = le32_to_cpu(fl->fl_pg_pool);
1109 pgid.pool = le32_to_cpu(fl->fl_pg_pool); 1108 pool = __lookup_pg_pool(&osdmap->pg_pools, pg->pool);
1110 pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool);
1111 if (!pool) 1109 if (!pool)
1112 return -EIO; 1110 return -EIO;
1113 pgid.seed = ceph_str_hash(pool->object_hash, oid, strlen(oid)); 1111 pg->seed = ceph_str_hash(pool->object_hash, oid, strlen(oid));
1114 num = pool->pg_num; 1112 num = pool->pg_num;
1115 num_mask = pool->pg_num_mask; 1113 num_mask = pool->pg_num_mask;
1116 1114
1117 dout("calc_object_layout '%s' pgid %lld.%x\n", oid, pgid.pool, 1115 dout("calc_object_layout '%s' pgid %lld.%x\n", oid, pg->pool, pg->seed);
1118 pgid.seed);
1119
1120 ol->ol_pgid.ps = cpu_to_le16(pgid.seed);
1121 ol->ol_pgid.pool = fl->fl_pg_pool;
1122 ol->ol_pgid.preferred = cpu_to_le16(-1);
1123 ol->ol_stripe_unit = fl->fl_object_stripe_unit;
1124 return 0; 1116 return 0;
1125} 1117}
1126EXPORT_SYMBOL(ceph_calc_object_layout); 1118EXPORT_SYMBOL(ceph_calc_object_layout);