static int ca_load(struct count_array *ca, struct dm_space_map *sm) { int r; uint32_t count; dm_block_t nr_blocks, i; r = dm_sm_get_nr_blocks(sm, &nr_blocks); if (r) return r; BUG_ON(ca->nr != nr_blocks); DMWARN("Loading debug space map from disk. This may take some time"); for (i = 0; i < nr_blocks; i++) { r = dm_sm_get_count(sm, i, &count); if (r) { DMERR("load failed"); return r; } ca_set_count(ca, i, count); } DMWARN("Load complete"); return 0; }
static int ca_create(struct count_array *ca, struct dm_space_map *sm) { int r; dm_block_t nr_blocks; r = dm_sm_get_nr_blocks(sm, &nr_blocks); if (r) return r; ca->nr = nr_blocks; ca->nr_free = nr_blocks; ca->counts = kzalloc(sizeof(*ca->counts) * nr_blocks, GFP_KERNEL); if (!ca->counts) return -ENOMEM; return 0; }
static int ca_create(struct count_array *ca, struct dm_space_map *sm) { int r; dm_block_t nr_blocks; r = dm_sm_get_nr_blocks(sm, &nr_blocks); if (r) return r; ca->nr = nr_blocks; ca->nr_free = nr_blocks; if (!nr_blocks) ca->counts = NULL; else { ca->counts = vzalloc(sizeof(*ca->counts) * nr_blocks); if (!ca->counts) return -ENOMEM; } return 0; }