LIBFMSR
0.1
|
Contains prototypes for functions implemented in fmsr.c, main include file accessed by third-party applications. More...
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | fmsr_repair_hints |
struct to hold hints from user to speed up repair process. More... | |
Defines | |
#define | alloc_encode_matrix(k, n) (gf *)malloc(fmsr_nc(k, n) * fmsr_nn(k, n)) |
#define | alloc_repair_matrix(k, n) (gf *)malloc(fmsr_chunks_per_node(k, n) * (n-1)) |
#define | alloc_native_chunks(k, n, filesize) (gf *)malloc(fmsr_padded_size(k, n, filesize)) |
#define | alloc_code_chunks(k, n, filesize) (gf *)malloc(fmsr_nc(k, n) * fmsr_padded_size(k, n, filesize)/fmsr_nn(k, n)) |
#define | alloc_decode_chunk_indices(k, n) (gf *)malloc(fmsr_nn(k, n)) |
#define | alloc_decode_chunks(k, n, chunksize) (gf *)malloc(fmsr_nn(k, n) * chunksize) |
#define | alloc_chunks_to_retrieve(k, n) (gf *)malloc(n-1) |
#define | alloc_retrieved_chunks(k, n, chunksize) (gf *)malloc((n-1) * chunksize) |
#define | alloc_new_code_chunks(k, n, chunksize) (gf *)malloc(fmsr_chunks_per_node(k, n) * chunksize) |
Functions | |
void | fmsr_init (void) |
Must be called first before using any core functions in the library. | |
gf | fmsr_nodeid (gf k, gf n, gf index) |
Returns id of the node where the index-th chunk resides, or 255 on failure. | |
gf | fmsr_chunks_per_node (gf k, gf n) |
Returns the number of chunks per node, or 255 on failure. | |
gf | fmsr_chunks_on_node (gf k, gf n, gf node, gf *chunk_indices) |
Returns the indices of chunks on a certain node through chunk_indices, or 255 on failure. | |
gf | fmsr_nn (gf k, gf n) |
Returns the number of native chunks. | |
gf | fmsr_nc (gf k, gf n) |
Returns the number of code chunks. | |
size_t | fmsr_padded_size (gf k, gf n, size_t size) |
Returns the size of input file after being padded. | |
int | fmsr_encode (gf k, gf n, gf *data, size_t data_size, int create_new, gf *code_chunks, gf *encode_matrix) |
Splits file into native chunks and encodes into code chunks. | |
int | fmsr_decode (gf k, gf n, gf *code_chunks, size_t chunk_size, gf *chunk_indices, gf num_chunks, gf *encode_matrix, gf *decode_matrix, int create_new, gf *data, size_t *data_size) |
Decodes code chunks to give the original data. | |
int | fmsr_repair (gf k, gf n, gf *encode_matrix, gf *erasures, gf num_erasures, fmsr_repair_hints *hints, gf *new_encode_matrix, gf *repair_matrix, gf *chunks_to_retrieve, gf *num_chunks_to_retrieve) |
Informs caller of the chunks and encoding matrix used in repair. | |
void | fmsr_regenerate (gf *repair_matrix, gf rows, gf cols, gf *retrieved_chunks, size_t chunk_size, gf *new_code_chunks) |
Generates new code_chunks from existing code_chunks. |
Contains prototypes for functions implemented in fmsr.c, main include file accessed by third-party applications.
#define alloc_chunks_to_retrieve | ( | k, | |
n | |||
) | (gf *)malloc(n-1) |
#define alloc_code_chunks | ( | k, | |
n, | |||
filesize | |||
) | (gf *)malloc(fmsr_nc(k, n) * fmsr_padded_size(k, n, filesize)/fmsr_nn(k, n)) |
#define alloc_decode_chunk_indices | ( | k, | |
n | |||
) | (gf *)malloc(fmsr_nn(k, n)) |
#define alloc_decode_chunks | ( | k, | |
n, | |||
chunksize | |||
) | (gf *)malloc(fmsr_nn(k, n) * chunksize) |
#define alloc_encode_matrix | ( | k, | |
n | |||
) | (gf *)malloc(fmsr_nc(k, n) * fmsr_nn(k, n)) |
#define alloc_native_chunks | ( | k, | |
n, | |||
filesize | |||
) | (gf *)malloc(fmsr_padded_size(k, n, filesize)) |
#define alloc_new_code_chunks | ( | k, | |
n, | |||
chunksize | |||
) | (gf *)malloc(fmsr_chunks_per_node(k, n) * chunksize) |
#define alloc_repair_matrix | ( | k, | |
n | |||
) | (gf *)malloc(fmsr_chunks_per_node(k, n) * (n-1)) |
#define alloc_retrieved_chunks | ( | k, | |
n, | |||
chunksize | |||
) | (gf *)malloc((n-1) * chunksize) |
Returns the indices of chunks on a certain node through chunk_indices, or 255 on failure.
gf fmsr_chunks_per_node | ( | gf | k, |
gf | n | ||
) |
Returns the number of chunks per node, or 255 on failure.
int fmsr_decode | ( | gf | k, |
gf | n, | ||
gf * | code_chunks, | ||
size_t | chunk_size, | ||
gf * | chunk_indices, | ||
gf | num_chunks, | ||
gf * | encode_matrix, | ||
gf * | decode_matrix, | ||
int | create_new, | ||
gf * | data, | ||
size_t * | data_size | ||
) |
Decodes code chunks to give the original data.
[in] | k,n | (n,k)-FMSR |
[in] | code_chunks | retrieved code chunks |
[in] | chunk_size | size of each code chunk |
[in] | chunk_indices | indices of retrieved chunks |
[in] | num_chunks | number of chunks retrieved |
[in] | encode_matrix | original encoding matrix (can be NULL if decode_matrix is already supplied) |
[in,out] | decode_matrix | decoding matrix (can be NULL if not interested) |
[in] | create_new | if 0, use supplied decode_matrix; else calculate and update decode_matrix |
[out] | data | decoded data (concat native chunks and unpad) |
[out] | data_size | size of decoded data |
int fmsr_encode | ( | gf | k, |
gf | n, | ||
gf * | data, | ||
size_t | data_size, | ||
int | create_new, | ||
gf * | code_chunks, | ||
gf * | encode_matrix | ||
) |
Splits file into native chunks and encodes into code chunks.
Note: sufficient memory should be allocated for the padded data (using fmsr_padded_size()), which is longer than data_size.
[in] | k,n | (n,k)-FMSR |
[in] | data | original unpadded file to be encoded |
[in] | data_size | unpadded file size |
[in] | create_new | if 0, use supplied encode_matrix; else generate and update encode_matrix |
[out] | code_chunks | code chunks from encoded data |
[in,out] | encode_matrix | encoding matrix |
void fmsr_init | ( | void | ) |
Must be called first before using any core functions in the library.
gf fmsr_nodeid | ( | gf | k, |
gf | n, | ||
gf | index | ||
) |
Returns id of the node where the index-th chunk resides, or 255 on failure.
size_t fmsr_padded_size | ( | gf | k, |
gf | n, | ||
size_t | size | ||
) |
Returns the size of input file after being padded.
void fmsr_regenerate | ( | gf * | repair_matrix, |
gf | rows, | ||
gf | cols, | ||
gf * | retrieved_chunks, | ||
size_t | chunk_size, | ||
gf * | new_code_chunks | ||
) |
Generates new code_chunks from existing code_chunks.
This is simply a single matrix multiplication that should be called after fmsr_repair().
[in] | repair_matrix | repair matrix obtained from fmsr_repair() |
[in] | rows,cols | number of rows and columns in repair_matrix |
[in] | retrieved_chunks | all code chunks retrieved for the repair |
[in] | chunk_size | size of each code chunk |
[out] | new_code_chunks | all code chunks newly generated by this function |
int fmsr_repair | ( | gf | k, |
gf | n, | ||
gf * | encode_matrix, | ||
gf * | erasures, | ||
gf | num_erasures, | ||
fmsr_repair_hints * | hints, | ||
gf * | new_encode_matrix, | ||
gf * | repair_matrix, | ||
gf * | chunks_to_retrieve, | ||
gf * | num_chunks_to_retrieve | ||
) |
Informs caller of the chunks and encoding matrix used in repair.
Most of the work during repair is done here.
[in] | k,n | (n,k)-FMSR |
[in] | encode_matrix | current encoding matrix before repair |
[in] | erasures | list of failed node indices |
[in] | num_erasures | number of failed nodes |
[in] | hints | refer to struct fmsr_repair_hints |
[out] | new_encode_matrix | new encoding matrix after repair |
[out] | repair_matrix | repair matrix (follows order given by chunk list below) |
[out] | chunks_to_retrieve | list of code chunks to retrieve from surviving nodes |
[out] | num_chunks_to_retrieve | number of code chunks to retrieve |