Separates the disk array in a disk list and a handle mapping vector.

This commit is contained in:
Andrea Mazzoleni 2011-09-23 21:48:50 +02:00
parent 7a10f95465
commit 99515f610c
10 changed files with 123 additions and 95 deletions

View file

@ -26,23 +26,23 @@
block_off_t parity_resize(struct snapraid_state* state)
{
unsigned diskmax = tommy_array_size(&state->diskarr);
block_off_t parity_block;
unsigned i;
tommy_node* i;
/* compute the size of the parity file */
parity_block = 0;
for(i=0;i<diskmax;++i) {
struct snapraid_disk* disk = tommy_array_get(&state->diskarr, i);
for(i=state->disklist;i!=0;i=i->next) {
struct snapraid_disk* disk = i->data;
/* start from the declared size */
block_off_t block = tommy_array_size(&disk->blockarr);
/* decrease the block until an allocated block */
while (block > 0 && tommy_array_get(&disk->blockarr, block - 1) == 0)
while (block > parity_block && tommy_array_get(&disk->blockarr, block - 1) == 0)
--block;
if (i == 0 || parity_block < block)
/* get the highest value */
if (block > parity_block)
parity_block = block;
}