diff options
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osdmap.c | 52 |
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 | */ | ||
1605 | static 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 | */ |
1602 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, | 1654 | int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, |