aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-03-24 11:12:47 -0400
committerSage Weil <sage@inktank.com>2014-04-05 00:08:11 -0400
commit45966c3467e8291382a8970adbd78403a7818d45 (patch)
tree7abbb04336ddbb9f72c4cbace25c5c902cb5b9da /net/ceph
parent2bd93d4d7ec2dd461cfb87c6d8a9b1ef9b30de08 (diff)
libceph: introduce apply_temps() helper
apply_temp() helper for applying various temporary mappings (at this point only pg_temp mappings) to the up set, therefore transforming it into an acting set. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osdmap.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index b8bbef058019..bd40f56b53ed 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1597,6 +1597,58 @@ static int raw_to_up_osds(struct ceph_osdmap *osdmap,
1597} 1597}
1598 1598
1599/* 1599/*
1600 * Given up set, apply pg_temp mapping.
1601 *
1602 * Return acting set length. *primary is set to acting primary osd id,
1603 * or -1 if acting set is empty.
1604 */
1605static int apply_temps(struct ceph_osdmap *osdmap,
1606 struct ceph_pg_pool_info *pool, struct ceph_pg pgid,
1607 int *osds, int len, int *primary)
1608{
1609 struct ceph_pg_mapping *pg;
1610 int temp_len;
1611 int temp_primary;
1612 int i;
1613
1614 /* raw_pg -> pg */
1615 pgid.seed = ceph_stable_mod(pgid.seed, pool->pg_num,
1616 pool->pg_num_mask);
1617
1618 /* pg_temp? */
1619 pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
1620 if (pg) {
1621 temp_len = 0;
1622 temp_primary = -1;
1623
1624 for (i = 0; i < pg->pg_temp.len; i++) {
1625 if (ceph_osd_is_down(osdmap, pg->pg_temp.osds[i])) {
1626 if (ceph_can_shift_osds(pool))
1627 continue;
1628 else
1629 osds[temp_len++] = CRUSH_ITEM_NONE;
1630 } else {
1631 osds[temp_len++] = pg->pg_temp.osds[i];
1632 }
1633 }
1634
1635 /* apply pg_temp's primary */
1636 for (i = 0; i < temp_len; i++) {
1637 if (osds[i] != CRUSH_ITEM_NONE) {
1638 temp_primary = osds[i];
1639 break;
1640 }
1641 }
1642 } else {
1643 temp_len = len;
1644 temp_primary = *primary;
1645 }
1646
1647 *primary = temp_primary;
1648 return temp_len;
1649}
1650
1651/*
1600 * Return acting set for given pgid. 1652 * Return acting set for given pgid.
1601 */ 1653 */
1602int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, 1654int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid,