diff options
author | Robert Buchholz <rbu@goodpoint.de> | 2012-07-09 09:22:38 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-07-09 09:22:38 +0200 |
commit | 59679536c5b74d3cf6d10e5bedf462606f18d33b (patch) | |
tree | bc6f2de31b3d5db9c686dba6e33daba6d9f4f4c0 /restripe.c | |
parent | Manage: simplify device searches in Manage_subdevs (diff) | |
download | mdadm-59679536c5b74d3cf6d10e5bedf462606f18d33b.tar.xz mdadm-59679536c5b74d3cf6d10e5bedf462606f18d33b.zip |
Extract function to generate zeroes and expose xor function
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'restripe.c')
-rw-r--r-- | restripe.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -211,7 +211,7 @@ static int is_ddf(int layout) } -static void xor_blocks(char *target, char **sources, int disks, int size) +void xor_blocks(char *target, char **sources, int disks, int size) { int i, j; /* Amazingly inefficient... */ @@ -335,6 +335,17 @@ void make_tables(void) uint8_t *zero; int zero_size; + +void ensure_zero_has_size(int chunk_size) +{ + if (zero == NULL || chunk_size > zero_size) { + if (zero) + free(zero); + zero = xcalloc(1, chunk_size); + zero_size = chunk_size; + } +} + /* Following was taken from linux/drivers/md/raid6recov.c */ /* Recover two failed data blocks. */ @@ -510,13 +521,7 @@ int save_stripes(int *source, unsigned long long *offsets, if (!tables_ready) make_tables(); - - if (zero == NULL || chunk_size > zero_size) { - if (zero) - free(zero); - zero = xcalloc(1, chunk_size); - zero_size = chunk_size; - } + ensure_zero_has_size(chunk_size); len = data_disks * chunk_size; length_test = length / len; |