diff --git a/cmdline/check.c b/cmdline/check.c index dbaf5503..9683ad4d 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -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); diff --git a/cmdline/io.c b/cmdline/io.c index d0fa8707..00d67ec7 100644 --- a/cmdline/io.c +++ b/cmdline/io.c @@ -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; diff --git a/cmdline/speed.c b/cmdline/speed.c index ac0980f2..fed92e68 100644 --- a/cmdline/speed.c +++ b/cmdline/speed.c @@ -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) diff --git a/cmdline/sync.c b/cmdline/sync.c index 045119f3..02ddbbb9 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -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); diff --git a/cmdline/util.c b/cmdline/util.c index 7e83a467..e45ee04c 100644 --- a/cmdline/util.c +++ b/cmdline/util.c @@ -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 */ diff --git a/cmdline/util.h b/cmdline/util.h index 2d377efd..2bc1339d 100644 --- a/cmdline/util.h +++ b/cmdline/util.h @@ -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. diff --git a/raid/memory.c b/raid/memory.c index c6a317d7..096d82cc 100644 --- a/raid/memory.c +++ b/raid/memory.c @@ -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) diff --git a/raid/memory.h b/raid/memory.h index 06f3155d..ee78420c 100644 --- a/raid/memory.h +++ b/raid/memory.h @@ -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. diff --git a/raid/module.c b/raid/module.c index 2219fd93..ab0f9fce 100644 --- a/raid/module.c +++ b/raid/module.c @@ -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; diff --git a/raid/test.c b/raid/test.c index 09fcbe53..2dbb819b 100644 --- a/raid/test.c +++ b/raid/test.c @@ -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; diff --git a/raid/test/speedtest.c b/raid/test/speedtest.c index 7c261850..8aab4416 100644 --- a/raid/test/speedtest.c +++ b/raid/test/speedtest.c @@ -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)