summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backends/shss/shss.c19
-rw-r--r--test/liberasurecode_test.c6
2 files changed, 11 insertions, 14 deletions
diff --git a/src/backends/shss/shss.c b/src/backends/shss/shss.c
index 8eb269b..a559b28 100644
--- a/src/backends/shss/shss.c
+++ b/src/backends/shss/shss.c
@@ -39,6 +39,7 @@
/* Forward declarations */
struct ec_backend shss;
struct ec_backend_op_stubs shss_ops;
+struct ec_backend_common backend_shss;
typedef int (*shss_encode_func)(char **, size_t, int, int, int, int, long long *);
typedef int (*shss_decode_func)(char **, size_t, int *, int, int, int, int, int, long long *);
@@ -66,18 +67,7 @@ struct shss_descriptor {
#define SHSS_SO_NAME "libshss.so"
#endif
#define DEFAULT_W 128
-
-/* TODO:
- metadata_adder is still in discussion. shss needs to a fixed value to allocate extra bytes
- for *each* fragment. However, current liberasurecode calculates the extra bytes as
- "(alined_data_size + metadata_adder) / k" so that shss has to define the METADATA as a big value
- to alloc enough memory for the maximum number of k even if k is smaller than the maximum value.
-
- i.e. (shss specification is)
- Enough Extra Bytes (for *each* fragment): 32
- The Maximum Number: 20 (k=20)
-*/
-#define METADATA 32 * 20
+#define METADATA 32
static int shss_encode(void *desc, char **data, char **parity,
int blocksize)
@@ -286,6 +276,10 @@ static int shss_exit(void *desc)
return 0;
}
+static bool shss_is_compatible_with(uint32_t version) {
+ return version == backend_shss.ec_backend_version;
+}
+
struct ec_backend_op_stubs shss_op_stubs = {
.INIT = shss_init,
.EXIT = shss_exit,
@@ -294,6 +288,7 @@ struct ec_backend_op_stubs shss_op_stubs = {
.FRAGSNEEDED = shss_fragments_needed,
.RECONSTRUCT = shss_reconstruct,
.ELEMENTSIZE = shss_element_size,
+ .ISCOMPATIBLEWITH = shss_is_compatible_with,
};
struct ec_backend_common backend_shss = {
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 3d9ef6c..7fb9557 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -621,7 +621,10 @@ static void encode_decode_test_impl(const ec_backend_id_t be_id,
assert(metadata.orig_data_size == orig_data_size);
char *data_ptr = frag + frag_header_size;
int cmp_size = remaining >= metadata.size ? metadata.size : remaining;
- assert(memcmp(data_ptr, orig_data_ptr, cmp_size) == 0);
+ // shss doesn't keep original data on data fragments
+ if (be_id != 5) {
+ assert(memcmp(data_ptr, orig_data_ptr, cmp_size) == 0);
+ }
remaining -= cmp_size;
orig_data_ptr += metadata.size;
}
@@ -629,7 +632,6 @@ static void encode_decode_test_impl(const ec_backend_id_t be_id,
num_avail_frags = create_frags_array(&avail_frags, encoded_data,
encoded_parity, args, skip);
assert(num_avail_frags != -1);
-
rc = liberasurecode_decode(desc, avail_frags, num_avail_frags,
encoded_fragment_len, 1,
&decoded_data, &decoded_data_len);