Lines Matching refs:map
722 struct ceph_pg_pool_info *ceph_pg_pool_by_id(struct ceph_osdmap *map, u64 id) in DEFINE_RB_FUNCS2()
724 return lookup_pg_pool(&map->pg_pools, id); in DEFINE_RB_FUNCS2()
727 const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_name_by_id() argument
737 pi = lookup_pg_pool(&map->pg_pools, id); in ceph_pg_pool_name_by_id()
742 int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name) in ceph_pg_poolid_by_name() argument
746 for (rbp = rb_first(&map->pg_pools); rbp; rbp = rb_next(rbp)) { in ceph_pg_poolid_by_name()
756 u64 ceph_pg_pool_flags(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_flags() argument
760 pi = lookup_pg_pool(&map->pg_pools, id); in ceph_pg_pool_flags()
936 static int decode_pool_names(void **p, void *end, struct ceph_osdmap *map) in decode_pool_names() argument
949 pi = lookup_pg_pool(&map->pg_pools, pool); in decode_pool_names()
1109 struct ceph_osdmap *map; in ceph_osdmap_alloc() local
1111 map = kzalloc(sizeof(*map), GFP_NOIO); in ceph_osdmap_alloc()
1112 if (!map) in ceph_osdmap_alloc()
1115 map->pg_pools = RB_ROOT; in ceph_osdmap_alloc()
1116 map->pool_max = -1; in ceph_osdmap_alloc()
1117 map->pg_temp = RB_ROOT; in ceph_osdmap_alloc()
1118 map->primary_temp = RB_ROOT; in ceph_osdmap_alloc()
1119 map->pg_upmap = RB_ROOT; in ceph_osdmap_alloc()
1120 map->pg_upmap_items = RB_ROOT; in ceph_osdmap_alloc()
1122 init_workspace_manager(&map->crush_wsm); in ceph_osdmap_alloc()
1124 return map; in ceph_osdmap_alloc()
1127 void ceph_osdmap_destroy(struct ceph_osdmap *map) in ceph_osdmap_destroy() argument
1129 dout("osdmap_destroy %p\n", map); in ceph_osdmap_destroy()
1131 if (map->crush) in ceph_osdmap_destroy()
1132 crush_destroy(map->crush); in ceph_osdmap_destroy()
1133 cleanup_workspace_manager(&map->crush_wsm); in ceph_osdmap_destroy()
1135 while (!RB_EMPTY_ROOT(&map->pg_temp)) { in ceph_osdmap_destroy()
1137 rb_entry(rb_first(&map->pg_temp), in ceph_osdmap_destroy()
1139 erase_pg_mapping(&map->pg_temp, pg); in ceph_osdmap_destroy()
1142 while (!RB_EMPTY_ROOT(&map->primary_temp)) { in ceph_osdmap_destroy()
1144 rb_entry(rb_first(&map->primary_temp), in ceph_osdmap_destroy()
1146 erase_pg_mapping(&map->primary_temp, pg); in ceph_osdmap_destroy()
1149 while (!RB_EMPTY_ROOT(&map->pg_upmap)) { in ceph_osdmap_destroy()
1151 rb_entry(rb_first(&map->pg_upmap), in ceph_osdmap_destroy()
1153 rb_erase(&pg->node, &map->pg_upmap); in ceph_osdmap_destroy()
1156 while (!RB_EMPTY_ROOT(&map->pg_upmap_items)) { in ceph_osdmap_destroy()
1158 rb_entry(rb_first(&map->pg_upmap_items), in ceph_osdmap_destroy()
1160 rb_erase(&pg->node, &map->pg_upmap_items); in ceph_osdmap_destroy()
1163 while (!RB_EMPTY_ROOT(&map->pg_pools)) { in ceph_osdmap_destroy()
1165 rb_entry(rb_first(&map->pg_pools), in ceph_osdmap_destroy()
1167 __remove_pg_pool(&map->pg_pools, pi); in ceph_osdmap_destroy()
1169 kvfree(map->osd_state); in ceph_osdmap_destroy()
1170 kvfree(map->osd_weight); in ceph_osdmap_destroy()
1171 kvfree(map->osd_addr); in ceph_osdmap_destroy()
1172 kvfree(map->osd_primary_affinity); in ceph_osdmap_destroy()
1173 kfree(map); in ceph_osdmap_destroy()
1181 static int osdmap_set_max_osd(struct ceph_osdmap *map, u32 max) in osdmap_set_max_osd() argument
1189 dout("%s old %u new %u\n", __func__, map->max_osd, max); in osdmap_set_max_osd()
1190 if (max == map->max_osd) in osdmap_set_max_osd()
1203 to_copy = min(map->max_osd, max); in osdmap_set_max_osd()
1204 if (map->osd_state) { in osdmap_set_max_osd()
1205 memcpy(state, map->osd_state, to_copy * sizeof(*state)); in osdmap_set_max_osd()
1206 memcpy(weight, map->osd_weight, to_copy * sizeof(*weight)); in osdmap_set_max_osd()
1207 memcpy(addr, map->osd_addr, to_copy * sizeof(*addr)); in osdmap_set_max_osd()
1208 kvfree(map->osd_state); in osdmap_set_max_osd()
1209 kvfree(map->osd_weight); in osdmap_set_max_osd()
1210 kvfree(map->osd_addr); in osdmap_set_max_osd()
1213 map->osd_state = state; in osdmap_set_max_osd()
1214 map->osd_weight = weight; in osdmap_set_max_osd()
1215 map->osd_addr = addr; in osdmap_set_max_osd()
1216 for (i = map->max_osd; i < max; i++) { in osdmap_set_max_osd()
1217 map->osd_state[i] = 0; in osdmap_set_max_osd()
1218 map->osd_weight[i] = CEPH_OSD_OUT; in osdmap_set_max_osd()
1219 memset(map->osd_addr + i, 0, sizeof(*map->osd_addr)); in osdmap_set_max_osd()
1222 if (map->osd_primary_affinity) { in osdmap_set_max_osd()
1230 memcpy(affinity, map->osd_primary_affinity, in osdmap_set_max_osd()
1232 kvfree(map->osd_primary_affinity); in osdmap_set_max_osd()
1234 map->osd_primary_affinity = affinity; in osdmap_set_max_osd()
1235 for (i = map->max_osd; i < max; i++) in osdmap_set_max_osd()
1236 map->osd_primary_affinity[i] = in osdmap_set_max_osd()
1240 map->max_osd = max; in osdmap_set_max_osd()
1245 static int osdmap_set_crush(struct ceph_osdmap *map, struct crush_map *crush) in osdmap_set_crush() argument
1258 if (map->crush) in osdmap_set_crush()
1259 crush_destroy(map->crush); in osdmap_set_crush()
1260 cleanup_workspace_manager(&map->crush_wsm); in osdmap_set_crush()
1261 map->crush = crush; in osdmap_set_crush()
1262 add_initial_workspace(&map->crush_wsm, work); in osdmap_set_crush()
1323 static int __decode_pools(void **p, void *end, struct ceph_osdmap *map, in __decode_pools() argument
1336 pi = lookup_pg_pool(&map->pg_pools, pool); in __decode_pools()
1345 if (!__insert_pg_pool(&map->pg_pools, pi)) { in __decode_pools()
1362 static int decode_pools(void **p, void *end, struct ceph_osdmap *map) in decode_pools() argument
1364 return __decode_pools(p, end, map, false); in decode_pools()
1367 static int decode_new_pools(void **p, void *end, struct ceph_osdmap *map) in decode_new_pools() argument
1369 return __decode_pools(p, end, map, true); in decode_new_pools()
1443 static int decode_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_pg_temp() argument
1445 return decode_pg_mapping(p, end, &map->pg_temp, __decode_pg_temp, in decode_pg_temp()
1449 static int decode_new_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_new_pg_temp() argument
1451 return decode_pg_mapping(p, end, &map->pg_temp, __decode_pg_temp, in decode_new_pg_temp()
1476 static int decode_primary_temp(void **p, void *end, struct ceph_osdmap *map) in decode_primary_temp() argument
1478 return decode_pg_mapping(p, end, &map->primary_temp, in decode_primary_temp()
1483 struct ceph_osdmap *map) in decode_new_primary_temp() argument
1485 return decode_pg_mapping(p, end, &map->primary_temp, in decode_new_primary_temp()
1489 u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd) in ceph_get_primary_affinity() argument
1491 BUG_ON(osd >= map->max_osd); in ceph_get_primary_affinity()
1493 if (!map->osd_primary_affinity) in ceph_get_primary_affinity()
1496 return map->osd_primary_affinity[osd]; in ceph_get_primary_affinity()
1499 static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) in set_primary_affinity() argument
1501 BUG_ON(osd >= map->max_osd); in set_primary_affinity()
1503 if (!map->osd_primary_affinity) { in set_primary_affinity()
1506 map->osd_primary_affinity = ceph_kvmalloc( in set_primary_affinity()
1507 array_size(map->max_osd, sizeof(*map->osd_primary_affinity)), in set_primary_affinity()
1509 if (!map->osd_primary_affinity) in set_primary_affinity()
1512 for (i = 0; i < map->max_osd; i++) in set_primary_affinity()
1513 map->osd_primary_affinity[i] = in set_primary_affinity()
1517 map->osd_primary_affinity[osd] = aff; in set_primary_affinity()
1523 struct ceph_osdmap *map) in decode_primary_affinity() argument
1529 kvfree(map->osd_primary_affinity); in decode_primary_affinity()
1530 map->osd_primary_affinity = NULL; in decode_primary_affinity()
1533 if (len != map->max_osd) in decode_primary_affinity()
1536 ceph_decode_need(p, end, map->max_osd*sizeof(u32), e_inval); in decode_primary_affinity()
1538 for (i = 0; i < map->max_osd; i++) { in decode_primary_affinity()
1541 ret = set_primary_affinity(map, i, ceph_decode_32(p)); in decode_primary_affinity()
1553 struct ceph_osdmap *map) in decode_new_primary_affinity() argument
1565 ret = set_primary_affinity(map, osd, aff); in decode_new_primary_affinity()
1584 static int decode_pg_upmap(void **p, void *end, struct ceph_osdmap *map) in decode_pg_upmap() argument
1586 return decode_pg_mapping(p, end, &map->pg_upmap, __decode_pg_upmap, in decode_pg_upmap()
1590 static int decode_new_pg_upmap(void **p, void *end, struct ceph_osdmap *map) in decode_new_pg_upmap() argument
1592 return decode_pg_mapping(p, end, &map->pg_upmap, __decode_pg_upmap, in decode_new_pg_upmap()
1596 static int decode_old_pg_upmap(void **p, void *end, struct ceph_osdmap *map) in decode_old_pg_upmap() argument
1598 return decode_pg_mapping(p, end, &map->pg_upmap, NULL, true); in decode_old_pg_upmap()
1628 static int decode_pg_upmap_items(void **p, void *end, struct ceph_osdmap *map) in decode_pg_upmap_items() argument
1630 return decode_pg_mapping(p, end, &map->pg_upmap_items, in decode_pg_upmap_items()
1635 struct ceph_osdmap *map) in decode_new_pg_upmap_items() argument
1637 return decode_pg_mapping(p, end, &map->pg_upmap_items, in decode_new_pg_upmap_items()
1642 struct ceph_osdmap *map) in decode_old_pg_upmap_items() argument
1644 return decode_pg_mapping(p, end, &map->pg_upmap_items, NULL, true); in decode_old_pg_upmap_items()
1651 struct ceph_osdmap *map) in osdmap_decode() argument
1667 ceph_decode_need(p, end, sizeof(map->fsid) + sizeof(u32) + in osdmap_decode()
1668 sizeof(map->created) + sizeof(map->modified), e_inval); in osdmap_decode()
1669 ceph_decode_copy(p, &map->fsid, sizeof(map->fsid)); in osdmap_decode()
1670 epoch = map->epoch = ceph_decode_32(p); in osdmap_decode()
1671 ceph_decode_copy(p, &map->created, sizeof(map->created)); in osdmap_decode()
1672 ceph_decode_copy(p, &map->modified, sizeof(map->modified)); in osdmap_decode()
1675 err = decode_pools(p, end, map); in osdmap_decode()
1680 err = decode_pool_names(p, end, map); in osdmap_decode()
1684 ceph_decode_32_safe(p, end, map->pool_max, e_inval); in osdmap_decode()
1686 ceph_decode_32_safe(p, end, map->flags, e_inval); in osdmap_decode()
1692 err = osdmap_set_max_osd(map, max); in osdmap_decode()
1698 map->max_osd*(struct_v >= 5 ? sizeof(u32) : in osdmap_decode()
1700 sizeof(*map->osd_weight), e_inval); in osdmap_decode()
1701 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1705 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1706 map->osd_state[i] = ceph_decode_32(p); in osdmap_decode()
1708 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1709 map->osd_state[i] = ceph_decode_8(p); in osdmap_decode()
1712 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1715 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1716 map->osd_weight[i] = ceph_decode_32(p); in osdmap_decode()
1718 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1721 for (i = 0; i < map->max_osd; i++) { in osdmap_decode()
1722 struct ceph_entity_addr *addr = &map->osd_addr[i]; in osdmap_decode()
1735 err = decode_pg_temp(p, end, map); in osdmap_decode()
1741 err = decode_primary_temp(p, end, map); in osdmap_decode()
1748 err = decode_primary_affinity(p, end, map); in osdmap_decode()
1752 WARN_ON(map->osd_primary_affinity); in osdmap_decode()
1757 err = osdmap_set_crush(map, crush_decode(*p, min(*p + len, end))); in osdmap_decode()
1769 err = decode_pg_upmap(p, end, map); in osdmap_decode()
1773 err = decode_pg_upmap_items(p, end, map); in osdmap_decode()
1777 WARN_ON(!RB_EMPTY_ROOT(&map->pg_upmap)); in osdmap_decode()
1778 WARN_ON(!RB_EMPTY_ROOT(&map->pg_upmap_items)); in osdmap_decode()
1784 dout("full osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_decode()
1803 struct ceph_osdmap *map; in ceph_osdmap_decode() local
1806 map = ceph_osdmap_alloc(); in ceph_osdmap_decode()
1807 if (!map) in ceph_osdmap_decode()
1810 ret = osdmap_decode(p, end, msgr2, map); in ceph_osdmap_decode()
1812 ceph_osdmap_destroy(map); in ceph_osdmap_decode()
1816 return map; in ceph_osdmap_decode()
1828 bool msgr2, struct ceph_osdmap *map) in decode_new_up_state_weight() argument
1866 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1870 map->osd_weight[osd] = w; in decode_new_up_state_weight()
1877 map->osd_state[osd] |= CEPH_OSD_EXISTS; in decode_new_up_state_weight()
1878 map->osd_state[osd] &= ~(CEPH_OSD_AUTOOUT | in decode_new_up_state_weight()
1898 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1899 if ((map->osd_state[osd] & CEPH_OSD_UP) && in decode_new_up_state_weight()
1902 if ((map->osd_state[osd] & CEPH_OSD_EXISTS) && in decode_new_up_state_weight()
1905 ret = set_primary_affinity(map, osd, in decode_new_up_state_weight()
1909 memset(map->osd_addr + osd, 0, sizeof(*map->osd_addr)); in decode_new_up_state_weight()
1910 map->osd_state[osd] = 0; in decode_new_up_state_weight()
1912 map->osd_state[osd] ^= xorstate; in decode_new_up_state_weight()
1924 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1935 map->osd_state[osd] |= CEPH_OSD_EXISTS | CEPH_OSD_UP; in decode_new_up_state_weight()
1936 map->osd_addr[osd] = addr; in decode_new_up_state_weight()
1950 struct ceph_osdmap *map) in osdmap_apply_incremental() argument
1974 BUG_ON(epoch != map->epoch+1); in osdmap_apply_incremental()
1990 err = osdmap_set_crush(map, in osdmap_apply_incremental()
1999 map->flags = new_flags; in osdmap_apply_incremental()
2001 map->pool_max = new_pool_max; in osdmap_apply_incremental()
2006 err = osdmap_set_max_osd(map, max); in osdmap_apply_incremental()
2011 map->epoch++; in osdmap_apply_incremental()
2012 map->modified = modified; in osdmap_apply_incremental()
2015 err = decode_new_pools(p, end, map); in osdmap_apply_incremental()
2020 err = decode_pool_names(p, end, map); in osdmap_apply_incremental()
2030 pi = lookup_pg_pool(&map->pg_pools, pool); in osdmap_apply_incremental()
2032 __remove_pg_pool(&map->pg_pools, pi); in osdmap_apply_incremental()
2036 err = decode_new_up_state_weight(p, end, struct_v, msgr2, map); in osdmap_apply_incremental()
2041 err = decode_new_pg_temp(p, end, map); in osdmap_apply_incremental()
2047 err = decode_new_primary_temp(p, end, map); in osdmap_apply_incremental()
2054 err = decode_new_primary_affinity(p, end, map); in osdmap_apply_incremental()
2068 err = decode_new_pg_upmap(p, end, map); in osdmap_apply_incremental()
2072 err = decode_old_pg_upmap(p, end, map); in osdmap_apply_incremental()
2076 err = decode_new_pg_upmap_items(p, end, map); in osdmap_apply_incremental()
2080 err = decode_old_pg_upmap_items(p, end, map); in osdmap_apply_incremental()
2088 dout("inc osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_apply_incremental()
2089 return map; in osdmap_apply_incremental()
2474 static int do_crush(struct ceph_osdmap *map, int ruleno, int x, in do_crush() argument
2485 arg_map = lookup_choose_arg_map(&map->crush->choose_args, in do_crush()
2488 arg_map = lookup_choose_arg_map(&map->crush->choose_args, in do_crush()
2491 work = get_workspace(&map->crush_wsm, map->crush); in do_crush()
2492 r = crush_do_rule(map->crush, ruleno, x, result, result_max, in do_crush()
2495 put_workspace(&map->crush_wsm, work); in do_crush()