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:13 -0400 |
commit | ac972230e20581b044f5ce66dcaf3c5af8d57444 (patch) | |
tree | 67395848522feb71f23079f8a950a73f3b7e7c29 /net | |
parent | 45966c3467e8291382a8970adbd78403a7818d45 (diff) |
libceph: switch ceph_calc_pg_acting() to new helpers
Switch ceph_calc_pg_acting() to new helpers: pg_to_raw_osds(),
raw_to_up_osds() and apply_temps().
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/osdmap.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index bd40f56b53ed..f1cad21d1533 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -1649,24 +1649,49 @@ static int apply_temps(struct ceph_osdmap *osdmap, | |||
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | /* | 1651 | /* |
1652 | * Return acting set for given pgid. | 1652 | * Calculate acting set for given pgid. |
1653 | * | ||
1654 | * Return acting set length, or error. | ||
1653 | */ | 1655 | */ |
1654 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, | 1656 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, |
1655 | int *acting) | 1657 | int *osds) |
1656 | { | 1658 | { |
1657 | int rawosds[CEPH_PG_MAX_SIZE], *osds; | 1659 | struct ceph_pg_pool_info *pool; |
1658 | int i, o, num = CEPH_PG_MAX_SIZE; | 1660 | u32 pps; |
1661 | int len; | ||
1662 | int primary; | ||
1659 | 1663 | ||
1660 | osds = calc_pg_raw(osdmap, pgid, rawosds, &num); | 1664 | pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); |
1661 | if (!osds) | 1665 | if (!pool) |
1662 | return -1; | 1666 | return 0; |
1663 | 1667 | ||
1664 | /* primary is first up osd */ | 1668 | if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { |
1665 | o = 0; | 1669 | /* hash pool id and seed so that pool PGs do not overlap */ |
1666 | for (i = 0; i < num; i++) | 1670 | pps = crush_hash32_2(CRUSH_HASH_RJENKINS1, |
1667 | if (ceph_osd_is_up(osdmap, osds[i])) | 1671 | ceph_stable_mod(pgid.seed, pool->pgp_num, |
1668 | acting[o++] = osds[i]; | 1672 | pool->pgp_num_mask), |
1669 | return o; | 1673 | pgid.pool); |
1674 | } else { | ||
1675 | /* | ||
1676 | * legacy behavior: add ps and pool together. this is | ||
1677 | * not a great approach because the PGs from each pool | ||
1678 | * will overlap on top of each other: 0.5 == 1.4 == | ||
1679 | * 2.3 == ... | ||
1680 | */ | ||
1681 | pps = ceph_stable_mod(pgid.seed, pool->pgp_num, | ||
1682 | pool->pgp_num_mask) + | ||
1683 | (unsigned)pgid.pool; | ||
1684 | } | ||
1685 | |||
1686 | len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); | ||
1687 | if (len < 0) | ||
1688 | return len; | ||
1689 | |||
1690 | len = raw_to_up_osds(osdmap, pool, osds, len, &primary); | ||
1691 | |||
1692 | len = apply_temps(osdmap, pool, pgid, osds, len, &primary); | ||
1693 | |||
1694 | return len; | ||
1670 | } | 1695 | } |
1671 | 1696 | ||
1672 | /* | 1697 | /* |