mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Separates the disk array in a disk list and a handle mapping vector.
This commit is contained in:
parent
7a10f95465
commit
99515f610c
10 changed files with 123 additions and 95 deletions
12
parity.c
12
parity.c
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue