Lines Matching refs:map
497 struct ceph_pg_pool_info *ceph_pg_pool_by_id(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_by_id() argument
499 return __lookup_pg_pool(&map->pg_pools, id); in ceph_pg_pool_by_id()
502 const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id) in ceph_pg_pool_name_by_id() argument
512 pi = __lookup_pg_pool(&map->pg_pools, (int) id); in ceph_pg_pool_name_by_id()
518 int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name) in ceph_pg_poolid_by_name() argument
522 for (rbp = rb_first(&map->pg_pools); rbp; rbp = rb_next(rbp)) { in ceph_pg_poolid_by_name()
620 static int decode_pool_names(void **p, void *end, struct ceph_osdmap *map) in decode_pool_names() argument
633 pi = __lookup_pg_pool(&map->pg_pools, pool); in decode_pool_names()
654 void ceph_osdmap_destroy(struct ceph_osdmap *map) in ceph_osdmap_destroy() argument
656 dout("osdmap_destroy %p\n", map); in ceph_osdmap_destroy()
657 if (map->crush) in ceph_osdmap_destroy()
658 crush_destroy(map->crush); in ceph_osdmap_destroy()
659 while (!RB_EMPTY_ROOT(&map->pg_temp)) { in ceph_osdmap_destroy()
661 rb_entry(rb_first(&map->pg_temp), in ceph_osdmap_destroy()
663 rb_erase(&pg->node, &map->pg_temp); in ceph_osdmap_destroy()
666 while (!RB_EMPTY_ROOT(&map->primary_temp)) { in ceph_osdmap_destroy()
668 rb_entry(rb_first(&map->primary_temp), in ceph_osdmap_destroy()
670 rb_erase(&pg->node, &map->primary_temp); in ceph_osdmap_destroy()
673 while (!RB_EMPTY_ROOT(&map->pg_pools)) { in ceph_osdmap_destroy()
675 rb_entry(rb_first(&map->pg_pools), in ceph_osdmap_destroy()
677 __remove_pg_pool(&map->pg_pools, pi); in ceph_osdmap_destroy()
679 kfree(map->osd_state); in ceph_osdmap_destroy()
680 kfree(map->osd_weight); in ceph_osdmap_destroy()
681 kfree(map->osd_addr); in ceph_osdmap_destroy()
682 kfree(map->osd_primary_affinity); in ceph_osdmap_destroy()
683 kfree(map); in ceph_osdmap_destroy()
691 static int osdmap_set_max_osd(struct ceph_osdmap *map, int max) in osdmap_set_max_osd() argument
698 state = krealloc(map->osd_state, max*sizeof(*state), GFP_NOFS); in osdmap_set_max_osd()
701 map->osd_state = state; in osdmap_set_max_osd()
703 weight = krealloc(map->osd_weight, max*sizeof(*weight), GFP_NOFS); in osdmap_set_max_osd()
706 map->osd_weight = weight; in osdmap_set_max_osd()
708 addr = krealloc(map->osd_addr, max*sizeof(*addr), GFP_NOFS); in osdmap_set_max_osd()
711 map->osd_addr = addr; in osdmap_set_max_osd()
713 for (i = map->max_osd; i < max; i++) { in osdmap_set_max_osd()
714 map->osd_state[i] = 0; in osdmap_set_max_osd()
715 map->osd_weight[i] = CEPH_OSD_OUT; in osdmap_set_max_osd()
716 memset(map->osd_addr + i, 0, sizeof(*map->osd_addr)); in osdmap_set_max_osd()
719 if (map->osd_primary_affinity) { in osdmap_set_max_osd()
722 affinity = krealloc(map->osd_primary_affinity, in osdmap_set_max_osd()
726 map->osd_primary_affinity = affinity; in osdmap_set_max_osd()
728 for (i = map->max_osd; i < max; i++) in osdmap_set_max_osd()
729 map->osd_primary_affinity[i] = in osdmap_set_max_osd()
733 map->max_osd = max; in osdmap_set_max_osd()
795 static int __decode_pools(void **p, void *end, struct ceph_osdmap *map, in __decode_pools() argument
808 pi = __lookup_pg_pool(&map->pg_pools, pool); in __decode_pools()
816 ret = __insert_pg_pool(&map->pg_pools, pi); in __decode_pools()
834 static int decode_pools(void **p, void *end, struct ceph_osdmap *map) in decode_pools() argument
836 return __decode_pools(p, end, map, false); in decode_pools()
839 static int decode_new_pools(void **p, void *end, struct ceph_osdmap *map) in decode_new_pools() argument
841 return __decode_pools(p, end, map, true); in decode_new_pools()
844 static int __decode_pg_temp(void **p, void *end, struct ceph_osdmap *map, in __decode_pg_temp() argument
861 ret = __remove_pg_mapping(&map->pg_temp, pgid); in __decode_pg_temp()
881 ret = __insert_pg_mapping(pg, &map->pg_temp); in __decode_pg_temp()
895 static int decode_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_pg_temp() argument
897 return __decode_pg_temp(p, end, map, false); in decode_pg_temp()
900 static int decode_new_pg_temp(void **p, void *end, struct ceph_osdmap *map) in decode_new_pg_temp() argument
902 return __decode_pg_temp(p, end, map, true); in decode_new_pg_temp()
905 static int __decode_primary_temp(void **p, void *end, struct ceph_osdmap *map, in __decode_primary_temp() argument
922 ret = __remove_pg_mapping(&map->primary_temp, pgid); in __decode_primary_temp()
935 ret = __insert_pg_mapping(pg, &map->primary_temp); in __decode_primary_temp()
949 static int decode_primary_temp(void **p, void *end, struct ceph_osdmap *map) in decode_primary_temp() argument
951 return __decode_primary_temp(p, end, map, false); in decode_primary_temp()
955 struct ceph_osdmap *map) in decode_new_primary_temp() argument
957 return __decode_primary_temp(p, end, map, true); in decode_new_primary_temp()
960 u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd) in ceph_get_primary_affinity() argument
962 BUG_ON(osd >= map->max_osd); in ceph_get_primary_affinity()
964 if (!map->osd_primary_affinity) in ceph_get_primary_affinity()
967 return map->osd_primary_affinity[osd]; in ceph_get_primary_affinity()
970 static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) in set_primary_affinity() argument
972 BUG_ON(osd >= map->max_osd); in set_primary_affinity()
974 if (!map->osd_primary_affinity) { in set_primary_affinity()
977 map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32), in set_primary_affinity()
979 if (!map->osd_primary_affinity) in set_primary_affinity()
982 for (i = 0; i < map->max_osd; i++) in set_primary_affinity()
983 map->osd_primary_affinity[i] = in set_primary_affinity()
987 map->osd_primary_affinity[osd] = aff; in set_primary_affinity()
993 struct ceph_osdmap *map) in decode_primary_affinity() argument
999 kfree(map->osd_primary_affinity); in decode_primary_affinity()
1000 map->osd_primary_affinity = NULL; in decode_primary_affinity()
1003 if (len != map->max_osd) in decode_primary_affinity()
1006 ceph_decode_need(p, end, map->max_osd*sizeof(u32), e_inval); in decode_primary_affinity()
1008 for (i = 0; i < map->max_osd; i++) { in decode_primary_affinity()
1011 ret = set_primary_affinity(map, i, ceph_decode_32(p)); in decode_primary_affinity()
1023 struct ceph_osdmap *map) in decode_new_primary_affinity() argument
1035 ret = set_primary_affinity(map, osd, aff); in decode_new_primary_affinity()
1051 static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) in osdmap_decode() argument
1067 ceph_decode_need(p, end, sizeof(map->fsid) + sizeof(u32) + in osdmap_decode()
1068 sizeof(map->created) + sizeof(map->modified), e_inval); in osdmap_decode()
1069 ceph_decode_copy(p, &map->fsid, sizeof(map->fsid)); in osdmap_decode()
1070 epoch = map->epoch = ceph_decode_32(p); in osdmap_decode()
1071 ceph_decode_copy(p, &map->created, sizeof(map->created)); in osdmap_decode()
1072 ceph_decode_copy(p, &map->modified, sizeof(map->modified)); in osdmap_decode()
1075 err = decode_pools(p, end, map); in osdmap_decode()
1080 err = decode_pool_names(p, end, map); in osdmap_decode()
1084 ceph_decode_32_safe(p, end, map->pool_max, e_inval); in osdmap_decode()
1086 ceph_decode_32_safe(p, end, map->flags, e_inval); in osdmap_decode()
1092 err = osdmap_set_max_osd(map, max); in osdmap_decode()
1098 map->max_osd*(1 + sizeof(*map->osd_weight) + in osdmap_decode()
1099 sizeof(*map->osd_addr)), e_inval); in osdmap_decode()
1101 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1104 ceph_decode_copy(p, map->osd_state, map->max_osd); in osdmap_decode()
1106 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1109 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1110 map->osd_weight[i] = ceph_decode_32(p); in osdmap_decode()
1112 if (ceph_decode_32(p) != map->max_osd) in osdmap_decode()
1115 ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); in osdmap_decode()
1116 for (i = 0; i < map->max_osd; i++) in osdmap_decode()
1117 ceph_decode_addr(&map->osd_addr[i]); in osdmap_decode()
1120 err = decode_pg_temp(p, end, map); in osdmap_decode()
1126 err = decode_primary_temp(p, end, map); in osdmap_decode()
1133 err = decode_primary_affinity(p, end, map); in osdmap_decode()
1138 kfree(map->osd_primary_affinity); in osdmap_decode()
1139 map->osd_primary_affinity = NULL; in osdmap_decode()
1144 map->crush = crush_decode(*p, min(*p + len, end)); in osdmap_decode()
1145 if (IS_ERR(map->crush)) { in osdmap_decode()
1146 err = PTR_ERR(map->crush); in osdmap_decode()
1147 map->crush = NULL; in osdmap_decode()
1155 dout("full osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_decode()
1174 struct ceph_osdmap *map; in ceph_osdmap_decode() local
1177 map = kzalloc(sizeof(*map), GFP_NOFS); in ceph_osdmap_decode()
1178 if (!map) in ceph_osdmap_decode()
1181 map->pg_temp = RB_ROOT; in ceph_osdmap_decode()
1182 map->primary_temp = RB_ROOT; in ceph_osdmap_decode()
1183 mutex_init(&map->crush_scratch_mutex); in ceph_osdmap_decode()
1185 ret = osdmap_decode(p, end, map); in ceph_osdmap_decode()
1187 ceph_osdmap_destroy(map); in ceph_osdmap_decode()
1191 return map; in ceph_osdmap_decode()
1198 struct ceph_osdmap *map, in osdmap_apply_incremental() argument
1224 BUG_ON(epoch != map->epoch+1); in osdmap_apply_incremental()
1251 map->flags = new_flags; in osdmap_apply_incremental()
1253 map->pool_max = new_pool_max; in osdmap_apply_incremental()
1258 err = osdmap_set_max_osd(map, max); in osdmap_apply_incremental()
1263 map->epoch++; in osdmap_apply_incremental()
1264 map->modified = modified; in osdmap_apply_incremental()
1266 if (map->crush) in osdmap_apply_incremental()
1267 crush_destroy(map->crush); in osdmap_apply_incremental()
1268 map->crush = newcrush; in osdmap_apply_incremental()
1273 err = decode_new_pools(p, end, map); in osdmap_apply_incremental()
1278 err = decode_pool_names(p, end, map); in osdmap_apply_incremental()
1288 pi = __lookup_pg_pool(&map->pg_pools, pool); in osdmap_apply_incremental()
1290 __remove_pg_pool(&map->pg_pools, pi); in osdmap_apply_incremental()
1302 BUG_ON(osd >= map->max_osd); in osdmap_apply_incremental()
1303 map->osd_state[osd] |= CEPH_OSD_UP; in osdmap_apply_incremental()
1304 map->osd_addr[osd] = addr; in osdmap_apply_incremental()
1319 if (osd < map->max_osd) in osdmap_apply_incremental()
1320 map->osd_state[osd] ^= xorstate; in osdmap_apply_incremental()
1333 if (osd < map->max_osd) in osdmap_apply_incremental()
1334 map->osd_weight[osd] = off; in osdmap_apply_incremental()
1338 err = decode_new_pg_temp(p, end, map); in osdmap_apply_incremental()
1344 err = decode_new_primary_temp(p, end, map); in osdmap_apply_incremental()
1351 err = decode_new_primary_affinity(p, end, map); in osdmap_apply_incremental()
1359 dout("inc osdmap epoch %d max_osd %d\n", map->epoch, map->max_osd); in osdmap_apply_incremental()
1360 return map; in osdmap_apply_incremental()
1474 static int do_crush(struct ceph_osdmap *map, int ruleno, int x, in do_crush() argument
1482 mutex_lock(&map->crush_scratch_mutex); in do_crush()
1483 r = crush_do_rule(map->crush, ruleno, x, result, result_max, in do_crush()
1484 weight, weight_max, map->crush_scratch_ary); in do_crush()
1485 mutex_unlock(&map->crush_scratch_mutex); in do_crush()