Make 'w' part of common user args, set 'w' in backend init

Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
Tushar Gohad 2014-07-17 15:08:35 -07:00
parent 184e656d26
commit e30f788f9a
4 changed files with 16 additions and 7 deletions

View File

@ -47,10 +47,10 @@ typedef enum {
EC_BACKENDS_MAX,
} ec_backend_id_t;
#ifdef EC_BACKENDS_SUPPORTED
#ifndef EC_BACKENDS_SUPPORTED
#define EC_BACKENDS_SUPPORTED
/* Supported EC backends */
const char *ec_backend_names[EC_BACKENDS_MAX] = {
static const char *ec_backend_names[EC_BACKENDS_MAX] = {
"null",
"jerasure_rs_vand",
"jerasure_rs_cauchy",
@ -67,14 +67,12 @@ const char *ec_backend_names[EC_BACKENDS_MAX] = {
struct ec_args {
int k; /* number of data fragments */
int m; /* number of parity fragments */
int w; /* word size, in bits (optional) */
union {
struct {
int hd; /* hamming distance (typically 3 or 4) */
int hd; /* hamming distance (3 or 4) */
} flat_xor_hd_args; /* args specific to XOR codes */
struct {
int w; /* word size in bits */
} jerasure_args; /* Jerasure specific args */
struct {
uint64_t x, y; /* reserved for future expansion */
uint64_t z, a; /* reserved for future expansion */

View File

@ -26,6 +26,7 @@
#define _ERASURECODE_INTERNAL_H_
#include "list.h"
#include "erasurecode.h"
#include "erasurecode_stdinc.h"
/* ~=*=~===~=*=~==~=*=~==~=*=~= backend infrastructure =~=*=~==~=*=~==~=*=~ */

View File

@ -137,6 +137,7 @@ static int jerasure_rs_vand_min_fragments(void *desc, int *missing_idxs, int *fr
// can implement this.
}
#define DEFAULT_W 16
static void * jerasure_rs_vand_init(struct ec_backend_args *args, void *backend_sohandle)
{
struct jerasure_rs_vand_descriptor *desc = (struct jerasure_rs_vand_descriptor *)
@ -148,7 +149,12 @@ static void * jerasure_rs_vand_init(struct ec_backend_args *args, void *backend_
desc->k = args->uargs.k;
desc->m = args->uargs.m;
desc->w = args->uargs.priv_args1.jerasure_args.w;
if (args->uargs.w <= 0)
args->uargs.w = DEFAULT_W;
/* store w back in args so upper layer can get to it */
desc->w = args->uargs.w;
/* validate EC arguments */
{

View File

@ -79,12 +79,16 @@ static int flat_xor_hd_min_fragments(void *desc,
xor_desc->fragments_needed(xor_desc, missing_idxs, fragments_needed);
}
#define DEFAULT_W 32
static void * flat_xor_hd_init(struct ec_backend_args *args, void *sohandle)
{
int k = args->uargs.k;
int m = args->uargs.m;
int hd = args->uargs.priv_args1.flat_xor_hd_args.hd;
/* store w back in args so upper layer can get to it */
args->uargs.w = DEFAULT_W;
struct flat_xor_hd_descriptor *bdesc = (struct flat_xor_hd_descriptor *)
malloc(sizeof(struct flat_xor_hd_descriptor));