summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backends/isa-l/isa_l_vand.c1
-rw-r--r--src/backends/jerasure/jerasure_rs_cauchy.c1
-rw-r--r--src/backends/jerasure/jerasure_rs_vand.c1
-rw-r--r--src/backends/null/null.c1
-rw-r--r--src/backends/xor/flat_xor_hd.c1
-rw-r--r--src/erasurecode.c4
-rw-r--r--src/erasurecode_helpers.c10
-rw-r--r--src/erasurecode_preprocessing.c18
8 files changed, 26 insertions, 11 deletions
diff --git a/src/backends/isa-l/isa_l_vand.c b/src/backends/isa-l/isa_l_vand.c
index fe11696..e7a575e 100644
--- a/src/backends/isa-l/isa_l_vand.c
+++ b/src/backends/isa-l/isa_l_vand.c
@@ -588,4 +588,5 @@ struct ec_backend_common backend_isa_l_rs_vand = {
#endif
.soversion = "2.0",
.ops = &isa_l_rs_vand_op_stubs,
+ .metadata_adder = 0,
};
diff --git a/src/backends/jerasure/jerasure_rs_cauchy.c b/src/backends/jerasure/jerasure_rs_cauchy.c
index 1c8b528..9d8466a 100644
--- a/src/backends/jerasure/jerasure_rs_cauchy.c
+++ b/src/backends/jerasure/jerasure_rs_cauchy.c
@@ -384,4 +384,5 @@ struct ec_backend_common backend_jerasure_rs_cauchy = {
#endif
.soversion = "2.0",
.ops = &jerasure_rs_cauchy_op_stubs,
+ .metadata_adder = 0,
};
diff --git a/src/backends/jerasure/jerasure_rs_vand.c b/src/backends/jerasure/jerasure_rs_vand.c
index 5866cd5..a8a8257 100644
--- a/src/backends/jerasure/jerasure_rs_vand.c
+++ b/src/backends/jerasure/jerasure_rs_vand.c
@@ -325,4 +325,5 @@ struct ec_backend_common backend_jerasure_rs_vand = {
#endif
.soversion = "2.0",
.ops = &jerasure_rs_vand_op_stubs,
+ .metadata_adder = 0,
};
diff --git a/src/backends/null/null.c b/src/backends/null/null.c
index f71312c..6ca5c98 100644
--- a/src/backends/null/null.c
+++ b/src/backends/null/null.c
@@ -223,5 +223,6 @@ struct ec_backend_common backend_null = {
#endif
.soversion = "1.0",
.ops = &null_op_stubs,
+ .metadata_adder = 0,
};
diff --git a/src/backends/xor/flat_xor_hd.c b/src/backends/xor/flat_xor_hd.c
index 289f36e..0979b30 100644
--- a/src/backends/xor/flat_xor_hd.c
+++ b/src/backends/xor/flat_xor_hd.c
@@ -170,5 +170,6 @@ struct ec_backend_common backend_flat_xor_hd = {
#endif
.soversion = "1.0",
.ops = &flat_xor_hd_op_stubs,
+ .metadata_adder = 0,
};
diff --git a/src/erasurecode.c b/src/erasurecode.c
index b3d1395..61cd269 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -598,7 +598,7 @@ int liberasurecode_decode(int desc,
* (realloc_bm).
*
*/
- ret = prepare_fragments_for_decode(k, m,
+ ret = prepare_fragments_for_decode(instance, k, m,
data, parity, missing_idxs,
&orig_data_size, &blocksize,
fragment_len, &realloc_bm);
@@ -765,7 +765,7 @@ int liberasurecode_reconstruct_fragment(int desc,
* It passes back a bitmap telling us which buffers need to be freed by
* us (realloc_bm).
*/
- ret = prepare_fragments_for_decode(k, m, data, parity, missing_idxs,
+ ret = prepare_fragments_for_decode(instance, k, m, data, parity, missing_idxs,
&orig_data_size, &blocksize,
fragment_len, &realloc_bm);
if (ret < 0) {
diff --git a/src/erasurecode_helpers.c b/src/erasurecode_helpers.c
index 6e4c882..42877eb 100644
--- a/src/erasurecode_helpers.c
+++ b/src/erasurecode_helpers.c
@@ -103,14 +103,20 @@ void * check_and_free_buffer(void * buf)
return NULL;
}
-char *alloc_fragment_buffer(int size)
+char *alloc_fragment_buffer(ec_backend_t instance, int size)
{
char *buf;
fragment_header_t *header = NULL;
+ if (NULL != instance) {
+ /* Account for any custom backend metadata in the fragment size */
+ size += instance->common.metadata_adder;
+ }
+
+ /* liberasurecode metadata */
size += sizeof(fragment_header_t);
- buf = get_aligned_buffer16(size);
+ buf = get_aligned_buffer16(size);
if (buf) {
header = (fragment_header_t *) buf;
header->magic = LIBERASURECODE_FRAG_HEADER_MAGIC;
diff --git a/src/erasurecode_preprocessing.c b/src/erasurecode_preprocessing.c
index c3e5ed6..ec471fb 100644
--- a/src/erasurecode_preprocessing.c
+++ b/src/erasurecode_preprocessing.c
@@ -49,7 +49,7 @@ int prepare_fragments_for_encode(ec_backend_t instance,
for (i = 0; i < k; i++) {
int payload_size = data_len > bsize ? bsize : data_len;
- char *fragment = (char *) alloc_fragment_buffer(bsize);
+ char *fragment = (char *) alloc_fragment_buffer(instance, bsize);
if (NULL == fragment) {
ret = -ENOMEM;
goto out_error;
@@ -67,7 +67,7 @@ int prepare_fragments_for_encode(ec_backend_t instance,
}
for (i = 0; i < m; i++) {
- char *fragment = (char *) alloc_fragment_buffer(bsize);
+ char *fragment = (char *) alloc_fragment_buffer(instance, bsize);
if (NULL == fragment) {
ret = -ENOMEM;
goto out_error;
@@ -107,7 +107,7 @@ out_error:
* case, the caller has to free up in the success case, so it may as well do
* so in the failure case.
*/
-int prepare_fragments_for_decode(
+int prepare_fragments_for_decode(ec_backend_t instance,
int k, int m,
char **data, char **parity,
int *missing_idxs,
@@ -135,14 +135,16 @@ int prepare_fragments_for_decode(
* 'data_list'
*/
if (NULL == data[i]) {
- data[i] = alloc_fragment_buffer(fragment_size - sizeof(fragment_header_t));
+ data[i] = alloc_fragment_buffer(instance,
+ fragment_size - sizeof(fragment_header_t));
if (NULL == data[i]) {
log_error("Could not allocate data buffer!");
return -1;
}
*realloc_bm = *realloc_bm | (1 << i);
} else if (!is_addr_aligned((unsigned long)data[i], 16)) {
- char *tmp_buf = alloc_fragment_buffer(fragment_size - sizeof(fragment_header_t));
+ char *tmp_buf = alloc_fragment_buffer(instance,
+ fragment_size - sizeof(fragment_header_t));
memcpy(tmp_buf, data[i], fragment_size);
data[i] = tmp_buf;
*realloc_bm = *realloc_bm | (1 << i);
@@ -170,14 +172,16 @@ int prepare_fragments_for_decode(
* DO NOT FREE: the python GC should free the original when cleaning up 'data_list'
*/
if (NULL == parity[i]) {
- parity[i] = alloc_fragment_buffer(fragment_size-sizeof(fragment_header_t));
+ parity[i] = alloc_fragment_buffer(instance,
+ fragment_size - sizeof(fragment_header_t));
if (NULL == parity[i]) {
log_error("Could not allocate parity buffer!");
return -1;
}
*realloc_bm = *realloc_bm | (1 << (k + i));
} else if (!is_addr_aligned((unsigned long)parity[i], 16)) {
- char *tmp_buf = alloc_fragment_buffer(fragment_size-sizeof(fragment_header_t));
+ char *tmp_buf = alloc_fragment_buffer(instance,
+ fragment_size - sizeof(fragment_header_t));
memcpy(tmp_buf, parity[i], fragment_size);
parity[i] = tmp_buf;
*realloc_bm = *realloc_bm | (1 << (k + i));