mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04: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
7a7dacc6db
commit
76998613da
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -970,9 +970,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.
|
||||
|
|
|
|||
|
|
@ -118,15 +118,13 @@ static const unsigned STRIDE_NOISE[16] = {
|
|||
1, 4, 0, 7, 3, 6, 2, 5
|
||||
};
|
||||
|
||||
void **raid_malloc_vector_align(int nd, int n, size_t size, size_t align_size, ssize_t displacement_size, void **freeptr)
|
||||
void **raid_malloc_vector_align(int n, size_t size, size_t align_size, ssize_t displacement_size, void **freeptr)
|
||||
{
|
||||
void **v;
|
||||
unsigned char *va;
|
||||
int i;
|
||||
|
||||
BUG_ON(n <= 0 || nd < 0);
|
||||
|
||||
(void)nd;
|
||||
BUG_ON(n <= 0);
|
||||
|
||||
v = malloc(n * sizeof(void *));
|
||||
if (!v) {
|
||||
|
|
@ -165,9 +163,9 @@ void **raid_malloc_vector_align(int nd, int n, size_t size, size_t align_size, s
|
|||
return v;
|
||||
}
|
||||
|
||||
void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr)
|
||||
void **raid_malloc_vector(int n, size_t size, void **freeptr)
|
||||
{
|
||||
return raid_malloc_vector_align(nd, n, size, RAID_MALLOC_ALIGN, raid_optimal_displacement(n), freeptr);
|
||||
return raid_malloc_vector_align(n, size, RAID_MALLOC_ALIGN, raid_optimal_displacement(n), freeptr);
|
||||
}
|
||||
|
||||
void raid_mrand_vector(unsigned seed, int n, size_t size, void **vv)
|
||||
|
|
|
|||
|
|
@ -82,14 +82,13 @@ void *raid_malloc_align(size_t size, size_t align_size, void **freeptr);
|
|||
* Use an alignment suitable for the raid functions.
|
||||
* Returns a vector of @n pointers, each one pointing to a block of
|
||||
* the specified @size.
|
||||
* The first @nd elements are reversed in order.
|
||||
*/
|
||||
void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr);
|
||||
void **raid_malloc_vector(int n, size_t size, void **freeptr);
|
||||
|
||||
/**
|
||||
* Arbitrary aligned vector allocation.
|
||||
*/
|
||||
void **raid_malloc_vector_align(int nd, int n, size_t size, size_t align_size, ssize_t displacement_size, void **freeptr);
|
||||
void **raid_malloc_vector_align(int n, size_t size, size_t align_size, ssize_t displacement_size, void **freeptr);
|
||||
|
||||
/**
|
||||
* Fills the memory vector with pseudo-random data based on the specified seed.
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ int raid_selftest(void)
|
|||
/* ensure to have enough space for data */
|
||||
BUG_ON(nd * size > 65536);
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
v = raid_malloc_vector(nv, size, &v_alloc);
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ int raid_test_rec(int mode, int nd, size_t size)
|
|||
|
||||
nv = nd + np * 2 + 2;
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
v = raid_malloc_vector(nv, size, &v_alloc);
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
|
|
@ -336,7 +336,7 @@ int raid_test_par(int mode, int nd, size_t size)
|
|||
|
||||
nv = nd + np * 2;
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
v = raid_malloc_vector(nv, size, &v_alloc);
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void speed(void)
|
|||
|
||||
nv = nd + RAID_PARITY_MAX + 1;
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
v = raid_malloc_vector(nv, size, &v_alloc);
|
||||
|
||||
/* initialize disks with fixed data */
|
||||
for (i = 0; i < nd; ++i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue