diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-03-01 02:21:14 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-03-01 02:21:14 +0000 |
commit | 26e47421407634a270806ff396d99c69f3fa861c (patch) | |
tree | 1797c57c4b6af34cb0cf766d6de48f443b8ef16e /src/erasurecode_preprocessing.c | |
parent | 4ab1336cabe0c1f5d7fc18c21b78f5d21aca5b60 (diff) | |
parent | 06e50ea86b6de729fa5dbc23ef41af87b19e636a (diff) | |
download | liberasurecode-26e47421407634a270806ff396d99c69f3fa861c.tar.gz |
Merge "Add Phazr.IO libphazr backend to liberasurecode"
Diffstat (limited to 'src/erasurecode_preprocessing.c')
-rw-r--r-- | src/erasurecode_preprocessing.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/erasurecode_preprocessing.c b/src/erasurecode_preprocessing.c index 8492184..26ad261 100644 --- a/src/erasurecode_preprocessing.c +++ b/src/erasurecode_preprocessing.c @@ -43,12 +43,19 @@ int prepare_fragments_for_encode(ec_backend_t instance, int data_len; /* data len to write to fragment headers */ int aligned_data_len; /* EC algorithm compatible data length */ int buffer_size, payload_size = 0; + int metadata_size, data_offset = 0; /* Calculate data sizes, aligned_data_len guaranteed to be divisible by k*/ data_len = orig_data_size; aligned_data_len = get_aligned_data_size(instance, orig_data_size); *blocksize = payload_size = (aligned_data_len / k); - buffer_size = payload_size + instance->common.backend_metadata_size; + metadata_size = instance->common.ops->get_backend_metadata_size( + instance->desc.backend_desc, + *blocksize); + data_offset = instance->common.ops->get_encode_offset( + instance->desc.backend_desc, + metadata_size); + buffer_size = payload_size + metadata_size; for (i = 0; i < k; i++) { int copy_size = data_len > payload_size ? payload_size : data_len; @@ -62,7 +69,7 @@ int prepare_fragments_for_encode(ec_backend_t instance, encoded_data[i] = get_data_ptr_from_fragment(fragment); if (data_len > 0) { - memcpy(encoded_data[i], orig_data, copy_size); + memcpy(encoded_data[i] + data_offset, orig_data, copy_size); } orig_data += copy_size; @@ -357,7 +364,6 @@ int fragments_to_string(int k, int m, char* fragment_data = get_data_ptr_from_fragment(data[i]); int fragment_size = get_fragment_payload_size(data[i]); int payload_size = orig_data_size > fragment_size ? fragment_size : orig_data_size; - memcpy(internal_payload + string_off, fragment_data, payload_size); orig_data_size -= payload_size; string_off += payload_size; |