summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Greenan <kmg@box.com>2015-06-23 13:12:40 -0700
committerKevin Greenan <kmg@box.com>2015-06-23 13:12:40 -0700
commit5e6592d557e6d2006fa0dc176049c196784b336f (patch)
treea666c56b410b1b9973607154aeb19ad88522b4de
parent4480ccaa39ccea29faa124461e382604a0adf4ec (diff)
downloadliberasurecode-5e6592d557e6d2006fa0dc176049c196784b336f.tar.gz
This will prevent the backends from reconstructing a specific index, when it issimilar_to_issue_63
specified as "available" by the caller. I feel that only buggy code would do this... NOTE: In the future, we should return an error when this happens.
-rw-r--r--src/erasurecode.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c
index 82874ea..57054b9 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -729,6 +729,7 @@ int liberasurecode_reconstruct_fragment(int desc,
char **parity = NULL;
int *missing_idxs = NULL;
char *fragment_ptr = NULL;
+ int is_destination_missing = 0;
int k = -1;
int m = -1;
int i;
@@ -792,6 +793,33 @@ int liberasurecode_reconstruct_fragment(int desc,
}
/*
+ * Odd corner-case: If the caller passes in a destination_idx that
+ * is also included in the available fragments list, we should *not*
+ * try to reconstruct.
+ *
+ * For now, we will log a warning and do nothing. In the future, we
+ * should probably log and return an error.
+ *
+ */
+ i = 0;
+ while (missing_idxs[i] > -1) {
+ if (missing_idxs[i] == destination_idx) {
+ is_destination_missing = 1;
+ }
+ i++;
+ }
+
+ if (!is_destination_missing) {
+ if (destination_idx < k) {
+ fragment_ptr = data[destination_idx];
+ } else {
+ fragment_ptr = parity[destination_idx - k];
+ }
+ log_warn("Dest idx for reconstruction was supplied as available buffer!");
+ goto destination_available;
+ }
+
+ /*
* Preparing the fragments for reconstruction. This will alloc aligned
* buffers when unaligned buffers were passed in available_fragments.
* It passes back a bitmap telling us which buffers need to be freed by
@@ -833,6 +861,7 @@ int liberasurecode_reconstruct_fragment(int desc,
orig_data_size, blocksize, instance->args.uargs.ct,
set_chksum);
+destination_available:
/*
* Copy the reconstructed fragment to the output buffer
*