diff options
author | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-03-24 16:12:48 +0100 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2014-04-05 06:08:14 +0200 |
commit | 8008ab1080c1768b02d232dcfd9e161cd47cc9f7 (patch) | |
tree | a1f59c1f607a9e118a7047be73b7f93e4195d32e /net/ceph/osdmap.c | |
parent | libceph: switch ceph_calc_pg_acting() to new helpers (diff) | |
download | linux-8008ab1080c1768b02d232dcfd9e161cd47cc9f7.tar.xz linux-8008ab1080c1768b02d232dcfd9e161cd47cc9f7.zip |
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: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to '')
-rw-r--r-- | net/ceph/osdmap.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index f1cad21d1533..df9389ddd56c 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1651,19 +1651,21 @@ static int apply_temps(struct ceph_osdmap *osdmap, /* * 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 *osds) + int *osds, int *primary) { struct ceph_pg_pool_info *pool; u32 pps; int len; - int primary; pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); - if (!pool) - return 0; + if (!pool) { + *primary = -1; + return -ENOENT; + } if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { /* 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, } len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); - if (len < 0) + if (len < 0) { + *primary = -1; 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; } |