Lines Matching full:map

129  * Read a map from the specified filename.  A file contains multiple maps
157 * Write all mappings to the map file.
264 * Add the dRAID map to the file and write it out.
267 write_map_key(const char *filename, char *key, draid_map_t *map, in write_map_key() argument
292 /* Replace old map with the more balanced new map. */ in write_map_key()
295 /* The old map is preferable, keep it. */ in write_map_key()
302 fnvlist_add_uint64(cfg, MAP_SEED, map->dm_seed); in write_map_key()
303 fnvlist_add_uint64(cfg, MAP_CHECKSUM, map->dm_checksum); in write_map_key()
304 fnvlist_add_uint64(cfg, MAP_CHILDREN, map->dm_children); in write_map_key()
305 fnvlist_add_uint64(cfg, MAP_NPERMS, map->dm_nperms); in write_map_key()
306 fnvlist_add_uint8_array(cfg, MAP_PERMS, map->dm_perms, in write_map_key()
307 map->dm_children * map->dm_nperms * sizeof (uint8_t)); in write_map_key()
324 dump_map(draid_map_t *map, const char *key, double worst_ratio, in dump_map() argument
331 "avg_ratio: %2.03f\n", key, (u_longlong_t)map->dm_seed, in dump_map()
342 key, (u_longlong_t)map->dm_seed, in dump_map()
343 (u_longlong_t)map->dm_checksum, worst_ratio, avg_ratio, in dump_map()
344 (u_longlong_t)map->dm_children, in dump_map()
345 (u_longlong_t)map->dm_nperms); in dump_map()
349 for (int i = 0; i < map->dm_nperms; i++) { in dump_map()
351 for (int j = 0; j < map->dm_children; j++) { in dump_map()
352 printf("%3d%s ", map->dm_perms[ in dump_map()
353 i * map->dm_children + j], in dump_map()
354 j < map->dm_children - 1 ? in dump_map()
369 draid_map_t map; in dump_map_nv() local
375 map.dm_seed = fnvlist_lookup_uint64(cfg, MAP_SEED); in dump_map_nv()
376 map.dm_checksum = fnvlist_lookup_uint64(cfg, MAP_CHECKSUM); in dump_map_nv()
377 map.dm_children = fnvlist_lookup_uint64(cfg, MAP_CHILDREN); in dump_map_nv()
378 map.dm_nperms = fnvlist_lookup_uint64(cfg, MAP_NPERMS); in dump_map_nv()
379 map.dm_perms = fnvlist_lookup_uint8_array(cfg, MAP_PERMS, &c); in dump_map_nv()
381 dump_map(&map, key, (double)worst_ratio / 1000.0, in dump_map_nv()
404 * Allocate a new permutation map for evaluation.
410 draid_map_t *map; in alloc_new_map() local
413 map = malloc(sizeof (draid_map_t)); in alloc_new_map()
414 if (map == NULL) in alloc_new_map()
417 map->dm_children = children; in alloc_new_map()
418 map->dm_nperms = nperms; in alloc_new_map()
419 map->dm_seed = seed; in alloc_new_map()
420 map->dm_checksum = 0; in alloc_new_map()
422 error = vdev_draid_generate_perms(map, &map->dm_perms); in alloc_new_map()
424 free(map); in alloc_new_map()
428 *mapp = map; in alloc_new_map()
434 * Allocate the fixed permutation map for N children.
440 draid_map_t *map; in alloc_fixed_map() local
447 map = malloc(sizeof (draid_map_t)); in alloc_fixed_map()
448 if (map == NULL) in alloc_fixed_map()
451 memcpy(map, fixed_map, sizeof (draid_map_t)); in alloc_fixed_map()
452 VERIFY3U(map->dm_checksum, !=, 0); in alloc_fixed_map()
454 error = vdev_draid_generate_perms(map, &map->dm_perms); in alloc_fixed_map()
456 free(map); in alloc_fixed_map()
460 *mapp = map; in alloc_fixed_map()
466 * Free a permutation map.
469 free_map(draid_map_t *map) in free_map() argument
471 free(map->dm_perms); in free_map()
472 free(map); in free_map()
494 eval_resilver(draid_map_t *map, uint64_t groupwidth, uint64_t nspares, in eval_resilver() argument
497 uint64_t children = map->dm_children; in eval_resilver()
507 int *ios = calloc(map->dm_children, sizeof (uint64_t)); in eval_resilver()
512 for (int i = 0; i < map->dm_nperms; i++) { in eval_resilver()
513 uint8_t *row = &map->dm_perms[i * map->dm_children]; in eval_resilver()
517 uint64_t spareidx = map->dm_children - nspares; in eval_resilver()
552 ASSERT3U(spareidx, <, map->dm_children); in eval_resilver()
571 for (int i = 0; i < map->dm_children; i++) { in eval_resilver()
606 eval_decluster(draid_map_t *map, double *worst_ratiop, double *avg_ratiop) in eval_decluster() argument
608 uint64_t children = map->dm_children; in eval_decluster()
653 ratio = eval_resilver(map, groupwidth, in eval_decluster()
670 ratio = eval_resilver(map, in eval_decluster()
698 dump_map(map, "DEBUG", worst_ratio, *avg_ratiop, 2); in eval_decluster()
718 draid_map_t *map; in eval_maps() local
722 * Calculate the next seed and generate a new candidate map. in eval_maps()
725 vdev_draid_rand(map_seed), &map); in eval_maps()
739 eval_decluster(map, &worst_ratio, &avg_ratio); in eval_maps()
746 best_map = map; in eval_maps()
750 free_map(map); in eval_maps()
755 * After determining the best map generate a checksum over the full in eval_maps()
810 * 0 - Only log when a better map is added to the file. in draid_generate()
811 * 1 - Log the current best map for each child count. in draid_generate()
813 * 2 - Log the current best map for each child count. in draid_generate()
814 * More verbose includes most map fields. in draid_generate()
815 * 3 - Log the current best map for each child count. in draid_generate()
816 * Very verbose all fields including the full map. in draid_generate()
871 * Generate maps for all requested child counts. The best map for in draid_generate()
873 * already contains a better mapping this map will not be added. in draid_generate()
878 draid_map_t *map; in draid_generate() local
882 error = eval_maps(children, passes, map_seed, &map, in draid_generate()
896 error = write_map_key(filename, key, map, worst_ratio, in draid_generate()
899 /* The new map was added to the file. */ in draid_generate()
900 dump_map(map, key, worst_ratio, avg_ratio, in draid_generate()
903 /* The existing map was preferable and kept. */ in draid_generate()
911 free_map(map); in draid_generate()
929 * Verify each map in the file by generating its in-memory permutation array
979 * Lookup hardcoded permutation map for each valid number of children in draid_verify()
980 * and verify a generated map has the correct checksum. Then compare in draid_verify()
981 * the generated map values with the nvlist map values read from the in draid_verify()
987 draid_map_t *map; in draid_verify() local
992 error = alloc_fixed_map(children, &map); in draid_verify()
1009 free_map(map); in draid_verify()
1022 if (map->dm_seed != nv_seed) { in draid_verify()
1024 "0x%016llx\n", (u_longlong_t)map->dm_seed, in draid_verify()
1029 if (map->dm_checksum != nv_checksum) { in draid_verify()
1032 (u_longlong_t)map->dm_checksum, in draid_verify()
1037 if (map->dm_children != nv_children) { in draid_verify()
1039 "!= %llu\n", (u_longlong_t)map->dm_children, in draid_verify()
1044 if (map->dm_nperms != nv_nperms) { in draid_verify()
1046 "!= %llu\n", (u_longlong_t)map->dm_nperms, in draid_verify()
1052 if (map->dm_perms[i] != nv_perms[i]) { in draid_verify()
1055 (int)map->dm_perms[i], in draid_verify()
1070 eval_decluster(map, &worst_ratio, &avg_ratio); in draid_verify()
1100 free_map(map); in draid_verify()
1111 free_map(map); in draid_verify()
1313 * Merge the best map for each child count found in the listed files into