mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-20 06:56:28 -05:00
Remove the unused number of data disks from the vector allocation
The same addressing rules are applied to the parity disks because they are used as data disks during recovery operations.
This commit is contained in:
parent
287135e2c1
commit
9ce976232c
11 changed files with 21 additions and 24 deletions
|
|
@ -967,7 +967,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* we need 1 * data + 2 * parity + 1 * zero */
|
||||
buffermax = diskmax + 2 * state->level + 1;
|
||||
|
||||
buffer = malloc_nofail_vector_align(diskmax, buffermax, state->block_size, &buffer_alloc);
|
||||
buffer = malloc_nofail_vector_align(buffermax, state->block_size, &buffer_alloc);
|
||||
if (!state->opt.skip_self)
|
||||
mtest_vector(buffermax, state->block_size, buffer);
|
||||
|
||||
|
|
|
|||
|
|
@ -960,9 +960,9 @@ void io_init(struct snapraid_io* io, struct snapraid_state* state,
|
|||
allocated_size = 0;
|
||||
for (i = 0; i < io->io_max; ++i) {
|
||||
if (state->file_mode != ADVISE_DIRECT)
|
||||
io->buffer_map[i] = malloc_nofail_vector_align(handle_max, buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
io->buffer_map[i] = malloc_nofail_vector_align(buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
else
|
||||
io->buffer_map[i] = malloc_nofail_vector_direct(handle_max, buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
io->buffer_map[i] = malloc_nofail_vector_direct(buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
if (!state->opt.skip_self)
|
||||
mtest_vector(io->buffer_max, state->block_size, io->buffer_map[i]);
|
||||
allocated_size += block_size * buffer_max;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void speed(int period, int nd, int size)
|
|||
|
||||
nv = nd + RAID_PARITY_MAX + 1;
|
||||
|
||||
v = malloc_nofail_vector_align(nd, nv, size, &v_alloc);
|
||||
v = malloc_nofail_vector_align(nv, size, &v_alloc);
|
||||
|
||||
/* initialize disks with fixed data */
|
||||
for (i = 0; i < nd; ++i)
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
io_init(&io, state, state->opt.io_cache, buffermax, handle, diskmax, 0, sync_data_reader, 0, parity_handle, state->level, 0, 0, sync_parity_writer);
|
||||
|
||||
/* allocate the copy buffer */
|
||||
copy = malloc_nofail_vector_align(diskmax, diskmax, state->block_size, ©_alloc);
|
||||
copy = malloc_nofail_vector_align(diskmax, state->block_size, ©_alloc);
|
||||
|
||||
/* allocate and fill the zero buffer */
|
||||
zero = malloc_nofail_align(state->block_size, &zero_alloc);
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ void* malloc_nofail_direct(size_t size, void** freeptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr)
|
||||
void** malloc_nofail_vector_align(int n, size_t size, void** freeptr)
|
||||
{
|
||||
void* ptr;
|
||||
|
||||
ptr = raid_malloc_vector(nd, n, size, freeptr);
|
||||
ptr = raid_malloc_vector(n, size, freeptr);
|
||||
|
||||
if (!ptr) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -59,11 +59,11 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void** malloc_nofail_vector_direct(int nd, int n, size_t size, void** freeptr)
|
||||
void** malloc_nofail_vector_direct(int n, size_t size, void** freeptr)
|
||||
{
|
||||
void* ptr;
|
||||
|
||||
ptr = raid_malloc_vector_align(nd, n, size, direct_size(), 0, freeptr);
|
||||
ptr = raid_malloc_vector_align(n, size, direct_size(), 0, freeptr);
|
||||
|
||||
if (!ptr) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ void* malloc_nofail_direct(size_t size, void** freeptr);
|
|||
* Safe aligned vector allocation.
|
||||
* If no memory is available, it aborts.
|
||||
*/
|
||||
void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr);
|
||||
void** malloc_nofail_vector_align(int n, size_t size, void** freeptr);
|
||||
|
||||
/**
|
||||
* Safe page vector allocation. Usable for direct io.
|
||||
* If no memory is available, it aborts.
|
||||
*/
|
||||
void** malloc_nofail_vector_direct(int nd, int n, size_t size, void** freeptr);
|
||||
void** malloc_nofail_vector_direct(int n, size_t size, void** freeptr);
|
||||
|
||||
/**
|
||||
* Safe allocation with memory test.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue