From: Takanori Nakao Date: Mon, 15 Jun 2015 07:32:22 +0000 (+0900) Subject: erasure code: move shec.cc into ErasureCodeShec.cc X-Git-Tag: v9.0.3~74^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=11238881c441ea8ce1b812b0446739bef15ac695;p=ceph.git erasure code: move shec.cc into ErasureCodeShec.cc Signed-off-by: Takanori Nakao --- diff --git a/src/erasure-code/shec/ErasureCodeShec.cc b/src/erasure-code/shec/ErasureCodeShec.cc index 148525e6bbf..61a51d5a3c3 100644 --- a/src/erasure-code/shec/ErasureCodeShec.cc +++ b/src/erasure-code/shec/ErasureCodeShec.cc @@ -18,16 +18,23 @@ * */ +#include +#include +#include #include #include #include "common/debug.h" #include "ErasureCodeShec.h" #include "crush/CrushWrapper.h" #include "osd/osd_types.h" -#include "shec.h" extern "C" { #include "jerasure/include/jerasure.h" #include "jerasure/include/galois.h" + +#define talloc(type, num) (type *) malloc(sizeof(type)*(num)) + +extern int calc_determinant(int *matrix, int dim); +extern int* reed_sol_vandermonde_coding_matrix(int k, int m, int w); } #define dout_subsys ceph_subsys_osd @@ -116,8 +123,7 @@ int ErasureCodeShec::minimum_to_decode(const set &want_to_decode, } } - if (shec_make_decoding_matrix(true, k, m, w, matrix, erased, - avails, 0, dm_ids, minimum) < 0) { + if (shec_make_decoding_matrix(true, erased, avails, 0, dm_ids, minimum) < 0) { return -EIO; } @@ -270,8 +276,7 @@ int ErasureCodeShecReedSolomonVandermonde::shec_decode(int *erased, char **coding, int blocksize) { - return shec_matrix_decode(k, m, w, matrix, - erased, avails, data, coding, blocksize); + return shec_matrix_decode(erased, avails, data, coding, blocksize); } unsigned ErasureCodeShecReedSolomonVandermonde::get_alignment() const @@ -389,12 +394,26 @@ void ErasureCodeShecReedSolomonVandermonde::prepare() dout(10) << "[ cache tables ] creating coeff for k=" << k << " m=" << m << " c=" << c << " w=" << w << dendl; - matrix = shec_reedsolomon_coding_matrix(k, m, c, w, technique); + matrix = shec_reedsolomon_coding_matrix(technique); // either our new created table is stored or if it has been // created in the meanwhile the locally allocated table will be // freed by setEncodingTable matrix = tcache.setEncodingTable(technique, k, m, c, w, matrix); + + dout(10) << "matrix = " << dendl; + for (int i=0; i 0) { + mat[j] = '1'; + } else { + mat[j] = '0'; + } + } + mat[k] = '\0'; + dout(10) << mat << dendl; + } } else { matrix = *p_enc_table; } @@ -405,3 +424,298 @@ void ErasureCodeShecReedSolomonVandermonde::prepare() assert((technique == SINGLE) || (technique == MULTIPLE)); } + +// ErasureCodeShec:: +// Mearged from shec.cc. + +double ErasureCodeShec::shec_calc_recovery_efficiency1(int k, int m1, int m2, int c1, int c2){ + int r_eff_k[k]; + double r_e1; + int i, rr, cc, start, end; + int first_flag; + + if (m1 < c1 || m2 < c2) return -1; + if ((m1 == 0 && c1 != 0) || (m2 == 0 && c2 != 0)) return -1; + + for (i=0; i m){ + free(tmpmat); + return -1; + } + + mindup = k+1; + int minc[ek]; + for (i=0; i 0) dup++; + } + if (dup < mindup) { + det = calc_determinant(tmpmat, k); + if (det != 0) { + mindup = dup; + for (int i=0; i 0 && i < k; i++) { + if (erased[i]) { + jerasure_matrix_dotprod(k, w, decoding_matrix+(i*k), + dm_ids, i, data_ptrs, coding_ptrs, size); + edd--; + } + } + + /* Re-encode any erased coding devices */ + + for (i = 0; i < m; i++) { + if (erased[k+i]) { + jerasure_matrix_dotprod(k, w, matrix+(i*k), NULL, i+k, + data_ptrs, coding_ptrs, size); + } + } + + if (decoding_matrix != NULL) free(decoding_matrix); + + return 0; +} diff --git a/src/erasure-code/shec/ErasureCodeShec.h b/src/erasure-code/shec/ErasureCodeShec.h index a943f085972..9c6fd33f9ee 100644 --- a/src/erasure-code/shec/ErasureCodeShec.h +++ b/src/erasure-code/shec/ErasureCodeShec.h @@ -116,8 +116,17 @@ public: int blocksize) = 0; virtual unsigned get_alignment() const = 0; virtual void prepare() = 0; + + virtual int shec_matrix_decode(int *erased, int *avails, + char **data_ptrs, char **coding_ptrs, int size); + virtual int* shec_reedsolomon_coding_matrix(int is_single); + private: virtual int parse(const ErasureCodeProfile &profile) = 0; + + virtual double shec_calc_recovery_efficiency1(int k, int m1, int m2, int c1, int c2); + virtual int shec_make_decoding_matrix(bool prepare, int *erased, int *avails, + int *decoding_matrix, int *dm_ids, int *minimum); }; class ErasureCodeShecReedSolomonVandermonde : public ErasureCodeShec { diff --git a/src/erasure-code/shec/Makefile.am b/src/erasure-code/shec/Makefile.am index 148f1c30d0d..e4ca5f8e72f 100644 --- a/src/erasure-code/shec/Makefile.am +++ b/src/erasure-code/shec/Makefile.am @@ -5,7 +5,6 @@ libec_shec_la_SOURCES = \ erasure-code/shec/ErasureCodePluginShec.cc \ erasure-code/shec/ErasureCodeShec.cc \ erasure-code/shec/ErasureCodeShecTableCache.cc \ - erasure-code/shec/shec.cc \ erasure-code/shec/determinant.c \ erasure-code/jerasure/jerasure/src/cauchy.c \ erasure-code/jerasure/jerasure/src/galois.c \ @@ -26,7 +25,6 @@ libec_shec_la_SOURCES = \ noinst_HEADERS += \ erasure-code/shec/ErasureCodeShec.h \ erasure-code/shec/ErasureCodeShecTableCache.h \ - erasure-code/shec/shec.h \ erasure-code/jerasure/jerasure/include/cauchy.h \ erasure-code/jerasure/jerasure/include/galois.h \ erasure-code/jerasure/jerasure/include/jerasure.h \ @@ -51,8 +49,6 @@ libec_shec_la_CXXFLAGS= ${AM_CXXFLAGS} \ -I$(srcdir)/erasure-code/jerasure \ -I$(srcdir)/erasure-code/shec libec_shec_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS) -#libec_shec_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS) -#libec_shec_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex '.*__erasure_code_.*' libec_shec_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 if LINUX libec_shec_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*' diff --git a/src/erasure-code/shec/shec.cc b/src/erasure-code/shec/shec.cc deleted file mode 100644 index 18528a1dd47..00000000000 --- a/src/erasure-code/shec/shec.cc +++ /dev/null @@ -1,331 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2014 FUJITSU LIMITED - * Copyright (C) 2014, James S. Plank and Kevin Greenan - * - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - */ - -/* Jerasure's authors: - - Revision 2.x - 2014: James S. Plank and Kevin M. Greenan - Revision 1.2 - 2008: James S. Plank, Scott Simmerman and Catherine D. Schuman. - Revision 1.0 - 2007: James S. Plank - */ - -#include -#include -#include -#include - -#include "shec.h" - -extern "C"{ -#include "jerasure/include/jerasure.h" -#include "jerasure/include/reed_sol.h" - -#define talloc(type, num) (type *) malloc(sizeof(type)*(num)) - -extern int calc_determinant(int *matrix, int dim); -} - -double shec_calc_recovery_efficiency1(int k, int m1, int m2, int c1, int c2){ - int r_eff_k[k]; - double r_e1; - int i, rr, cc, start, end; - int first_flag; - - if (m1 < c1 || m2 < c2) return -1; - if ((m1 == 0 && c1 != 0) || (m2 == 0 && c2 != 0)) return -1; - - for (i=0; i m){ - free(tmpmat); - return -1; - } - - mindup = k+1; - int minc[ek]; - for (i=0; i 0) dup++; - } - if (dup < mindup) { - det = calc_determinant(tmpmat, k); - if (det != 0) { - mindup = dup; - for (int i=0; i 0 && i < k; i++) { - if (erased[i]) { - jerasure_matrix_dotprod(k, w, decoding_matrix+(i*k), - dm_ids, i, data_ptrs, coding_ptrs, size); - edd--; - } - } - - /* Re-encode any erased coding devices */ - - for (i = 0; i < m; i++) { - if (erased[k+i]) { - jerasure_matrix_dotprod(k, w, matrix+(i*k), NULL, i+k, - data_ptrs, coding_ptrs, size); - } - } - - if (decoding_matrix != NULL) free(decoding_matrix); - - return 0; -} diff --git a/src/erasure-code/shec/shec.h b/src/erasure-code/shec/shec.h deleted file mode 100755 index fe4471f08bb..00000000000 --- a/src/erasure-code/shec/shec.h +++ /dev/null @@ -1,35 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2014 FUJITSU LIMITED - * Copyright (C) 2014, James S. Plank and Kevin Greenan - * - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - */ - -/* Jerasure's authors: - - Revision 2.x - 2014: James S. Plank and Kevin M. Greenan - Revision 1.2 - 2008: James S. Plank, Scott Simmerman and Catherine D. Schuman. - Revision 1.0 - 2007: James S. Plank - */ - -#ifndef SHEC_H -#define SHEC_H - -int *shec_reedsolomon_coding_matrix(int k, int m, int c, int w, int is_single); -int shec_make_decoding_matrix(bool prepare, int k, int m, int w, int *matrix, - int *erased, int *avails, int *decoding_matrix, int *dm_ids, int *minimum); -int shec_matrix_decode(int k, int m, int w, int *matrix, - int *erased, int *avails, char **data_ptrs, char **coding_ptrs, int size); - -#endif