Commit 8008ab10 authored by Ilya Dryomov's avatar Ilya Dryomov Committed by Sage Weil

libceph: return primary from ceph_calc_pg_acting()

In preparation for adding support for primary_temp, stop assuming
primaryness: add a primary out parameter to ceph_calc_pg_acting() and
change call sites accordingly.  Primary is now specified separately
from the order of osds in the set.
Signed-off-by: default avatarIlya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent ac972230
...@@ -212,7 +212,7 @@ extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap, ...@@ -212,7 +212,7 @@ extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
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 *osds); int *osds, int *primary);
extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap, extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap,
struct ceph_pg pgid); struct ceph_pg pgid);
......
...@@ -1333,7 +1333,7 @@ static int __map_request(struct ceph_osd_client *osdc, ...@@ -1333,7 +1333,7 @@ static int __map_request(struct ceph_osd_client *osdc,
{ {
struct ceph_pg pgid; struct ceph_pg pgid;
int acting[CEPH_PG_MAX_SIZE]; int acting[CEPH_PG_MAX_SIZE];
int o = -1, num = 0; int num, o;
int err; int err;
bool was_paused; bool was_paused;
...@@ -1346,11 +1346,9 @@ static int __map_request(struct ceph_osd_client *osdc, ...@@ -1346,11 +1346,9 @@ static int __map_request(struct ceph_osd_client *osdc,
} }
req->r_pgid = pgid; req->r_pgid = pgid;
err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting); num = ceph_calc_pg_acting(osdc->osdmap, pgid, acting, &o);
if (err > 0) { if (num < 0)
o = acting[0]; num = 0;
num = err;
}
was_paused = req->r_paused; was_paused = req->r_paused;
req->r_paused = __req_should_be_paused(osdc, req); req->r_paused = __req_should_be_paused(osdc, req);
......
...@@ -1651,19 +1651,21 @@ static int apply_temps(struct ceph_osdmap *osdmap, ...@@ -1651,19 +1651,21 @@ static int apply_temps(struct ceph_osdmap *osdmap,
/* /*
* Calculate acting set for given pgid. * Calculate acting set for given pgid.
* *
* Return acting set length, or error. * Return acting set length, or error. *primary is set to acting
* primary osd id, or -1 if acting set is empty or on error.
*/ */
int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
int *osds) int *osds, int *primary)
{ {
struct ceph_pg_pool_info *pool; struct ceph_pg_pool_info *pool;
u32 pps; u32 pps;
int len; int len;
int primary;
pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool);
if (!pool) if (!pool) {
return 0; *primary = -1;
return -ENOENT;
}
if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) {
/* hash pool id and seed so that pool PGs do not overlap */ /* hash pool id and seed so that pool PGs do not overlap */
...@@ -1684,12 +1686,14 @@ int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, ...@@ -1684,12 +1686,14 @@ int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
} }
len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds);
if (len < 0) if (len < 0) {
*primary = -1;
return len; return len;
}
len = raw_to_up_osds(osdmap, pool, osds, len, &primary); len = raw_to_up_osds(osdmap, pool, osds, len, primary);
len = apply_temps(osdmap, pool, pgid, osds, len, &primary); len = apply_temps(osdmap, pool, pgid, osds, len, primary);
return len; return len;
} }
......
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