Stores the free space in the content file.

This avoids the need to access data and parity disks in
the status command.
Also removed some data disk access, in list, dup and similar
commands that don't need to scan the disks.
This commit is contained in:
Andrea Mazzoleni 2014-11-09 19:14:29 +01:00
parent 8ee1131bed
commit 7e9a5e6a6d
12 changed files with 519 additions and 128 deletions

View file

@ -649,6 +649,8 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev
disk->device = dev;
disk->tick = 0;
disk->total_blocks = 0;
disk->free_blocks = 0;
disk->first_free_block = 0;
disk->has_volatile_inodes = 0;
disk->has_unreliable_physical = 0;
@ -727,14 +729,16 @@ int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax)
return 1;
}
struct snapraid_map* map_alloc(const char* name, unsigned position, const char* uuid)
struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid)
{
struct snapraid_map* map;
map = malloc_nofail(sizeof(struct snapraid_map));
pathcpy(map->name, sizeof(map->name), name);
pathcpy(map->uuid, sizeof(map->uuid), uuid);
map->position = position;
map->total_blocks = total_blocks;
map->free_blocks = free_blocks;
pathcpy(map->uuid, sizeof(map->uuid), uuid);
return map;
}