diff options
author | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-03-24 11:12:48 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2014-04-05 00:08:14 -0400 |
commit | 8008ab1080c1768b02d232dcfd9e161cd47cc9f7 (patch) | |
tree | a1f59c1f607a9e118a7047be73b7f93e4195d32e /net | |
parent | ac972230e20581b044f5ce66dcaf3c5af8d57444 (diff) |
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 'net')
-rw-r--r-- | net/ceph/osd_client.c | 10 | ||||
-rw-r--r-- | net/ceph/osdmap.c | 20 |
2 files changed, 16 insertions, 14 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 6f64eec18851..b4157dc22199 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -1333,7 +1333,7 @@ static int __map_request(struct ceph_osd_client *osdc, | |||
1333 | { | 1333 | { |
1334 | struct ceph_pg pgid; | 1334 | struct ceph_pg pgid; |
1335 | int acting[CEPH_PG_MAX_SIZE]; | 1335 | int acting[CEPH_PG_MAX_SIZE]; |
1336 | int o = -1, num = 0; | 1336 | int num, o; |
1337 | int err; | 1337 | int err; |
1338 | bool was_paused; | 1338 | bool was_paused; |
1339 | 1339 | ||
@@ -1346,11 +1346,9 @@ static int __map_request(struct ceph_osd_client *osdc, | |||
1346 | } | 1346 | } |
1347 | req->r_pgid = pgid; | 1347 | req->r_pgid = pgid; |
1348 | 1348 | ||
1349 | err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting); | 1349 | num = ceph_calc_pg_acting(osdc->osdmap, pgid, acting, &o); |
1350 | if (err > 0) { | 1350 | if (num < 0) |
1351 | o = acting[0]; | 1351 | num = 0; |
1352 | num = err; | ||
1353 | } | ||
1354 | 1352 | ||
1355 | was_paused = req->r_paused; | 1353 | was_paused = req->r_paused; |
1356 | req->r_paused = __req_should_be_paused(osdc, req); | 1354 | req->r_paused = __req_should_be_paused(osdc, req); |
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, | |||
1651 | /* | 1651 | /* |
1652 | * Calculate acting set for given pgid. | 1652 | * Calculate acting set for given pgid. |
1653 | * | 1653 | * |
1654 | * Return acting set length, or error. | 1654 | * Return acting set length, or error. *primary is set to acting |
1655 | * primary osd id, or -1 if acting set is empty or on error. | ||
1655 | */ | 1656 | */ |
1656 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, | 1657 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, |
1657 | int *osds) | 1658 | int *osds, int *primary) |
1658 | { | 1659 | { |
1659 | struct ceph_pg_pool_info *pool; | 1660 | struct ceph_pg_pool_info *pool; |
1660 | u32 pps; | 1661 | u32 pps; |
1661 | int len; | 1662 | int len; |
1662 | int primary; | ||
1663 | 1663 | ||
1664 | pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); | 1664 | pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); |
1665 | if (!pool) | 1665 | if (!pool) { |
1666 | return 0; | 1666 | *primary = -1; |
1667 | return -ENOENT; | ||
1668 | } | ||
1667 | 1669 | ||
1668 | if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { | 1670 | if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { |
1669 | /* hash pool id and seed so that pool PGs do not overlap */ | 1671 | /* 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 | } | 1686 | } |
1685 | 1687 | ||
1686 | len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); | 1688 | len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); |
1687 | if (len < 0) | 1689 | if (len < 0) { |
1690 | *primary = -1; | ||
1688 | return len; | 1691 | return len; |
1692 | } | ||
1689 | 1693 | ||
1690 | len = raw_to_up_osds(osdmap, pool, osds, len, &primary); | 1694 | len = raw_to_up_osds(osdmap, pool, osds, len, primary); |
1691 | 1695 | ||
1692 | len = apply_temps(osdmap, pool, pgid, osds, len, &primary); | 1696 | len = apply_temps(osdmap, pool, pgid, osds, len, primary); |
1693 | 1697 | ||
1694 | return len; | 1698 | return len; |
1695 | } | 1699 | } |