33#include "erasurecode.h"
34#include "erasurecode_backend.h"
35#include "erasurecode_helpers.h"
37#define FLAT_XOR_LIB_MAJOR 1
38#define FLAT_XOR_LIB_MINOR 0
39#define FLAT_XOR_LIB_REV 0
40#define FLAT_XOR_LIB_VER_STR "1.0"
41#define FLAT_XOR_LIB_NAME "flat_xor_hd"
42#if defined(__MACOS__) || defined(__MACOSX__) || defined(__OSX__) || defined(__APPLE__)
43#define FLAT_XOR_SO_NAME "libXorcode" LIBERASURECODE_SO_SUFFIX ".dylib"
45#define FLAT_XOR_SO_NAME "libXorcode" LIBERASURECODE_SO_SUFFIX ".so.1"
52typedef xor_code_t* (*init_xor_hd_code_func)(int, int, int);
66 char **data,
char **parity,
int blocksize)
77 char **data,
char **parity,
int *missing_idxs,
88 char **data,
char **parity,
int *missing_idxs,
89 int destination_idx,
int blocksize)
96 missing_idxs, destination_idx, blocksize);
108 struct ec_bm missing_bm = NEW_BM;
109 convert_list_to_bitmap(missing_idxs, &missing_bm);
111 for (
int i = 0; i < EC_MAX_FRAGMENTS; i++)
112 if (bm_get_value(&missing_bm, i))
116 if (num_available < 2)
117 return -EINSUFFFRAGS;
121 return -EINSUFFFRAGS;
122 if (
xor_desc->k == 10 && num_available < 4)
123 return -EINSUFFFRAGS;
126 return -EINSUFFFRAGS;
128 return -EINSUFFFRAGS;
129 if (
xor_desc->k == 15 && num_available < 5)
130 return -EINSUFFFRAGS;
133 if (num_available < 3)
134 return -EINSUFFFRAGS;
138 return -EINSUFFFRAGS;
140 return -EINSUFFFRAGS;
143 return -EINSUFFFRAGS;
150 int *missing_idxs,
int *fragments_to_exclude,
151 int *fragments_needed)
157 xor_desc->fragments_needed(
xor_desc, missing_idxs, fragments_to_exclude, fragments_needed);
173 int k = args->uargs.k;
174 int m = args->uargs.m;
175 int hd = args->uargs.hd;
199 return (
void *) bdesc;
230 .GETMETADATASIZE = get_backend_metadata_size_zero,
231 .GETENCODEOFFSET = get_encode_offset_zero,
237 .id = EC_BACKEND_FLAT_XOR_HD,
static int flat_xor_hd_exit(void *desc)
struct ec_backend_common backend_flat_xor_hd
static int flat_xor_hd_reconstruct(void *desc, char **data, char **parity, int *missing_idxs, int destination_idx, int blocksize)
int(* xor_hd_fragments_needed_func)(xor_code_t *, int *, int *, int *)
static bool flat_xor_is_compatible_with(uint32_t version)
static int flar_xor_hd_element_size(void *desc)
Return the element-size, which is the number of bits stored on a given device, per codeword.
xor_code_t *(* init_xor_hd_code_func)(int, int, int)
static int flat_xor_hd_decode(void *desc, char **data, char **parity, int *missing_idxs, int blocksize)
#define FLAT_XOR_LIB_MINOR
int(* xor_code_decode_func)(xor_code_t *, char **, char **, int *, int, int)
void(* xor_code_encode_func)(xor_code_t *, char **, char **, int)
static struct ec_backend_op_stubs flat_xor_hd_op_stubs
static int flat_xor_hd_min_fragments(void *desc, int *missing_idxs, int *fragments_to_exclude, int *fragments_needed)
static int flat_xor_hd_encode(void *desc, char **data, char **parity, int blocksize)
#define FLAT_XOR_LIB_NAME
__attribute__((visibility("internal")))
static void * flat_xor_hd_init(struct ec_backend_args *args, void *sohandle)
#define FLAT_XOR_LIB_MAJOR
static int flat_xor_hd_check_reconstruct_fragments(void *desc, int *missing_idxs, int destination_idx)
#define FLAT_XOR_LIB_VER_STR
xor_code_encode_func xor_code_encode
xor_code_decode_func xor_code_decode
xor_hd_fragments_needed_func xor_hd_fragments_needed
init_xor_hd_code_func init_xor_hd_code
int xor_reconstruct_one(xor_code_t *code_desc, char **data, char **parity, int *missing_idxs, int index_to_reconstruct, int blocksize)
xor_code_t * init_xor_hd_code(int k, int m, int hd)