Lines Matching refs:map
472 struct ceph_pg_pool_info *ceph_pg_pool_by_id(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_by_id() argument
474 return __lookup_pg_pool(&map->pg_pools, id); in ceph_pg_pool_by_id()
477 const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_name_by_id() argument
487 pi = __lookup_pg_pool(&map->pg_pools, (int) id); in ceph_pg_pool_name_by_id()
493 int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name) in ceph_pg_poolid_by_name() argument
497 for (rbp = rb_first(&map->pg_pools); rbp; rbp = rb_next(rbp)) { in ceph_pg_poolid_by_name()
595 static int decode_pool_names(void **p, void *end, struct ceph_osdmap *map) in decode_pool_names() argument
608 pi = __lookup_pg_pool(&map->pg_pools, pool); in decode_pool_names()
629 void ceph_osdmap_destroy(struct ceph_osdmap *map) in ceph_osdmap_destroy() argument
631 dout("osdmap_destroy %p\n", map); in ceph_osdmap_destroy()
632 if (map->crush) in ceph_osdmap_destroy()
633 crush_destroy(map->crush); in ceph_osdmap_destroy()
634 while (!RB_EMPTY_ROOT(&map->pg_temp)) { in ceph_osdmap_destroy()
636 rb_entry(rb_first(&map->pg_temp), in ceph_osdmap_destroy()
638 rb_erase(&pg->node, &map->pg_temp); in ceph_osdmap_destroy()
641 while (!RB_EMPTY_ROOT(&map->primary_temp)) { in ceph_osdmap_destroy()
643 rb_entry(rb_first(&map->primary_temp), in ceph_osdmap_destroy()
645 rb_erase(&pg->node, &map->primary_temp); in ceph_osdmap_destroy()
648 while (!RB_EMPTY_ROOT(&map->pg_pools)) { in ceph_osdmap_destroy()
650 rb_entry(rb_first(&map->pg_pools), in ceph_osdmap_destroy()
652 __remove_pg_pool(&map->pg_pools, pi); in ceph_osdmap_destroy()
654 kfree(map->osd_state); in ceph_osdmap_destroy()
655 kfree(map->osd_weight); in ceph_osdmap_destroy()
656 kfree(map->osd_addr); in ceph_osdmap_destroy()
657 kfree(map->osd_primary_affinity); in ceph_osdmap_destroy()
658 kfree(map); in ceph_osdmap_destroy()
666 static int osdmap_set_max_osd(struct ceph_osdmap *map, int max) in osdmap_set_max_osd() argument
673 state = krealloc(map->osd_state, max*sizeof(*state), GFP_NOFS); in osdmap_set_max_osd()
676 map->osd_state = state; in osdmap_set_max_osd()
678 weight = krealloc(map->osd_weight, max*sizeof(*weight), GFP_NOFS); in osdmap_set_max_osd()
681 map->osd_weight = weight; in osdmap_set_max_osd()
683 addr = krealloc(map->osd_addr, max*sizeof(*addr), GFP_NOFS); in osdmap_set_max_osd()
686 map->osd_addr = addr; in osdmap_set_max_osd()
688 for (i = map->max_osd; i < max; i++) { in osdmap_set_max_osd()
689 map->osd_state[i] = 0; in osdmap_set_max_osd()
690 map->osd_weight[i] = CEPH_OSD_OUT; in osdmap_set_max_osd()
691 memset(map->osd_addr + i, 0, sizeof(*map->osd_addr)); in osdmap_set_max_osd()
694 if (map->osd_primary_affinity) { in osdmap_set_max_osd()
697 affinity = krealloc(map->osd_primary_affinity, in osdmap_set_max_osd()
701 map->osd_primary_affinity = affinity; in osdmap_set_max_osd()
703 for (i = map->max_osd; i < max; i++) in osdmap_set_max_osd()
704 map->osd_primary_affinity[i] = in osdmap_set_max_osd()
708 map->max_osd = max; in osdmap_set_max_osd()
770 static int __decode_pools(void **p, void *end, struct ceph_osdmap *map, in __decode_pools() argument
783 pi = __lookup_pg_pool(&map->pg_pools, pool); in __decode_pools()
791 ret = __insert_pg_pool(&map->pg_pools, pi); in __decode_pools()
809 static int decode_pools(void **p, void *end, struct ceph_osdmap *map) in decode_pools() argument
811 return __decode_pools(p, end, map, false); in decode_pools()
814 static int decode_new_pools(void **p, void *end, struct ceph_osdmap *map) in decode_new_pools() argument
816 return __decode_pools(p, end, map, true); in decode_new_pools()
819 static int __decode_pg_temp(void **p, void *end, struct ceph_osdmap *map, in __decode_pg_temp() argument
836 ret = __remove_pg_mapping(&map->pg_temp, pgid); in __decode_pg_temp()
856 ret = __insert_pg_mapping(pg, &map->pg_temp); in __decode_pg_temp()
870 static int decode_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_pg_temp() argument
872 return __decode_pg_temp(p, end, map, false); in decode_pg_temp()
875 static int decode_new_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_new_pg_temp() argument
877 return __decode_pg_temp(p, end, map, true); in decode_new_pg_temp()
880 static int __decode_primary_temp(void **p, void *end, struct ceph_osdmap *map, in __decode_primary_temp() argument
897 ret = __remove_pg_mapping(&map->primary_temp, pgid); in __decode_primary_temp()
910 ret = __insert_pg_mapping(pg, &map->primary_temp); in __decode_primary_temp()
924 static int decode_primary_temp(void **p, void *end, struct ceph_osdmap *map) in decode_primary_temp() argument
926 return __decode_primary_temp(p, end, map, false); in decode_primary_temp()
930 struct ceph_osdmap *map) in decode_new_primary_temp() argument
932 return __decode_primary_temp(p, end, map, true); in decode_new_primary_temp()
935 u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd) in ceph_get_primary_affinity() argument
937 BUG_ON(osd >= map->max_osd); in ceph_get_primary_affinity()
939 if (!map->osd_primary_affinity) in ceph_get_primary_affinity()
942 return map->osd_primary_affinity[osd]; in ceph_get_primary_affinity()
945 static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) in set_primary_affinity() argument
947 BUG_ON(osd >= map->max_osd); in set_primary_affinity()
949 if (!map->osd_primary_affinity) { in set_primary_affinity()
952 map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32), in set_primary_affinity()
954 if (!map->osd_primary_affinity) in set_primary_affinity()
957 for (i = 0; i < map->max_osd; i++) in set_primary_affinity()
958 map->osd_primary_affinity[i] = in set_primary_affinity()
962 map->osd_primary_affinity[osd] = aff; in set_primary_affinity()
968 struct ceph_osdmap *map) in decode_primary_affinity() argument
974 kfree(map->osd_primary_affinity); in decode_primary_affinity()
975 map->osd_primary_affinity = NULL; in decode_primary_affinity()
978 if (len != map->max_osd) in decode_primary_affinity()
981 ceph_decode_need(p, end, map->max_osd*sizeof(u32), e_inval); in decode_primary_affinity()
983 for (i = 0; i < map->max_osd; i++) { in decode_primary_affinity()
986 ret = set_primary_affinity(map, i, ceph_decode_32(p)); in decode_primary_affinity()
998 struct ceph_osdmap *map) in decode_new_primary_affinity() argument
1010 ret = set_primary_affinity(map, osd, aff); in decode_new_primary_affinity()
1026 static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) in osdmap_decode() argument
1042 ceph_decode_need(p, end, sizeof(map->fsid) + sizeof(u32) + in osdmap_decode()
1043 sizeof(map->created) + sizeof(map->modified), e_inval); in osdmap_decode()
1044 ceph_decode_copy(p, &map->fsid, sizeof(map->fsid)); in osdmap_decode()
1045 epoch = map->epoch = ceph_decode_32(p); in osdmap_decode()
1046 ceph_decode_copy(p, &map->created, sizeof(map->created)); in osdmap_decode()
1047 ceph_decode_copy(p, &map->modified, sizeof(map->modified)); in osdmap_decode()
1050 err = decode_pools(p, end, map); in osdmap_decode()
1055 err = decode_pool_names(p, end, map); in osdmap_decode()
1059 ceph_decode_32_safe(p, end, map->pool_max, e_inval); in osdmap_decode()
1061 ceph_decode_32_safe(p, end, map->flags, e_inval); in osdmap_decode()
1067 err = osdmap_set_max_osd(map, max); in osdmap_decode()
1073 map->max_osd*(1 + sizeof(*map->osd_weight) + in osdmap_decode()
1074 sizeof(*map->osd_addr)), e_inval); in osdmap_decode()
1076 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1079 ceph_decode_copy(p, map->osd_state, map->max_osd); in osdmap_decode()
1081 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1084 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1085 map->osd_weight[i] = ceph_decode_32(p); in osdmap_decode()
1087 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1090 ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); in osdmap_decode()
1091 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1092 ceph_decode_addr(&map->osd_addr[i]); in osdmap_decode()
1095 err = decode_pg_temp(p, end, map); in osdmap_decode()
1101 err = decode_primary_temp(p, end, map); in osdmap_decode()
1108 err = decode_primary_affinity(p, end, map); in osdmap_decode()
1113 kfree(map->osd_primary_affinity); in osdmap_decode()
1114 map->osd_primary_affinity = NULL; in osdmap_decode()
1119 map->crush = crush_decode(*p, min(*p + len, end)); in osdmap_decode()
1120 if (IS_ERR(map->crush)) { in osdmap_decode()
1121 err = PTR_ERR(map->crush); in osdmap_decode()
1122 map->crush = NULL; in osdmap_decode()
1130 dout("full osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_decode()
1149 struct ceph_osdmap *map; in ceph_osdmap_decode() local
1152 map = kzalloc(sizeof(*map), GFP_NOFS); in ceph_osdmap_decode()
1153 if (!map) in ceph_osdmap_decode()
1156 map->pg_temp = RB_ROOT; in ceph_osdmap_decode()
1157 map->primary_temp = RB_ROOT; in ceph_osdmap_decode()
1158 mutex_init(&map->crush_scratch_mutex); in ceph_osdmap_decode()
1160 ret = osdmap_decode(p, end, map); in ceph_osdmap_decode()
1162 ceph_osdmap_destroy(map); in ceph_osdmap_decode()
1166 return map; in ceph_osdmap_decode()
1178 struct ceph_osdmap *map) in decode_new_up_state_weight() argument
1206 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1210 map->osd_weight[osd] = w; in decode_new_up_state_weight()
1217 map->osd_state[osd] |= CEPH_OSD_EXISTS; in decode_new_up_state_weight()
1218 map->osd_state[osd] &= ~(CEPH_OSD_AUTOOUT | in decode_new_up_state_weight()
1236 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1237 if ((map->osd_state[osd] & CEPH_OSD_UP) && in decode_new_up_state_weight()
1240 if ((map->osd_state[osd] & CEPH_OSD_EXISTS) && in decode_new_up_state_weight()
1243 ret = set_primary_affinity(map, osd, in decode_new_up_state_weight()
1247 memset(map->osd_addr + osd, 0, sizeof(*map->osd_addr)); in decode_new_up_state_weight()
1248 map->osd_state[osd] = 0; in decode_new_up_state_weight()
1250 map->osd_state[osd] ^= xorstate; in decode_new_up_state_weight()
1264 BUG_ON(osd >= map->max_osd); in decode_new_up_state_weight()
1266 map->osd_state[osd] |= CEPH_OSD_EXISTS | CEPH_OSD_UP; in decode_new_up_state_weight()
1267 map->osd_addr[osd] = addr; in decode_new_up_state_weight()
1281 struct ceph_osdmap *map, in osdmap_apply_incremental() argument
1307 BUG_ON(epoch != map->epoch+1); in osdmap_apply_incremental()
1334 map->flags = new_flags; in osdmap_apply_incremental()
1336 map->pool_max = new_pool_max; in osdmap_apply_incremental()
1341 err = osdmap_set_max_osd(map, max); in osdmap_apply_incremental()
1346 map->epoch++; in osdmap_apply_incremental()
1347 map->modified = modified; in osdmap_apply_incremental()
1349 if (map->crush) in osdmap_apply_incremental()
1350 crush_destroy(map->crush); in osdmap_apply_incremental()
1351 map->crush = newcrush; in osdmap_apply_incremental()
1356 err = decode_new_pools(p, end, map); in osdmap_apply_incremental()
1361 err = decode_pool_names(p, end, map); in osdmap_apply_incremental()
1371 pi = __lookup_pg_pool(&map->pg_pools, pool); in osdmap_apply_incremental()
1373 __remove_pg_pool(&map->pg_pools, pi); in osdmap_apply_incremental()
1377 err = decode_new_up_state_weight(p, end, map); in osdmap_apply_incremental()
1382 err = decode_new_pg_temp(p, end, map); in osdmap_apply_incremental()
1388 err = decode_new_primary_temp(p, end, map); in osdmap_apply_incremental()
1395 err = decode_new_primary_affinity(p, end, map); in osdmap_apply_incremental()
1403 dout("inc osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_apply_incremental()
1404 return map; in osdmap_apply_incremental()
1518 static int do_crush(struct ceph_osdmap *map, int ruleno, int x, in do_crush() argument
1526 mutex_lock(&map->crush_scratch_mutex); in do_crush()
1527 r = crush_do_rule(map->crush, ruleno, x, result, result_max, in do_crush()
1528 weight, weight_max, map->crush_scratch_ary); in do_crush()
1529 mutex_unlock(&map->crush_scratch_mutex); in do_crush()