]>
git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/isa/ErasureCodeIsa.h
2 * Ceph - scalable distributed file system
4 * Copyright (C) 2014 CERN (Switzerland)
6 * Author: Andreas-Joachim Peters <Andreas.Joachim.Peters@cern.ch>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
16 * @file ErasureCodeIsa.cc
18 * @brief Erasure Code CODEC using the INTEL ISA-L library.
20 * The INTEL ISA-L library supports two pre-defined encoding matrices (cauchy = default, reed_sol_van = default)
21 * The default CODEC implementation using these two matrices is implemented in class ErasureCodeIsaDefault.
22 * ISA-L allows to use custom matrices which might be added later as implementations deriving from the base class ErasoreCodeIsa.
25 #ifndef CEPH_ERASURE_CODE_ISA_L_H
26 #define CEPH_ERASURE_CODE_ISA_L_H
28 // -----------------------------------------------------------------------------
29 #include "erasure-code/ErasureCode.h"
30 #include "ErasureCodeIsaTableCache.h"
31 // -----------------------------------------------------------------------------
33 class ErasureCodeIsa
: public ErasureCode
{
37 kVandermonde
= 0, kCauchy
= 1
44 ErasureCodeIsaTableCache
&tcache
;
45 const char *technique
;
47 ErasureCodeIsa(const char *_technique
,
48 ErasureCodeIsaTableCache
&_tcache
) :
58 ~ErasureCodeIsa() override
63 get_chunk_count() const override
69 get_data_chunk_count() const override
74 unsigned int get_chunk_size(unsigned int object_size
) const override
;
76 int encode_chunks(const std::set
<int> &want_to_encode
,
77 std::map
<int, bufferlist
> *encoded
) override
;
79 int decode_chunks(const std::set
<int> &want_to_read
,
80 const std::map
<int, bufferlist
> &chunks
,
81 std::map
<int, bufferlist
> *decoded
) override
;
83 int init(ErasureCodeProfile
&profile
, std::ostream
*ss
) override
;
85 virtual void isa_encode(char **data
,
90 virtual int isa_decode(int *erasures
,
95 virtual unsigned get_alignment() const = 0;
97 virtual void prepare() = 0;
100 virtual int parse(ErasureCodeProfile
&profile
,
101 std::ostream
*ss
) = 0;
104 // -----------------------------------------------------------------------------
106 class ErasureCodeIsaDefault
: public ErasureCodeIsa
{
112 static const std::string DEFAULT_K
;
113 static const std::string DEFAULT_M
;
115 unsigned char* encode_coeff
; // encoding coefficient
116 unsigned char* encode_tbls
; // encoding table
118 ErasureCodeIsaDefault(ErasureCodeIsaTableCache
&_tcache
,
119 int matrix
= kVandermonde
) :
121 ErasureCodeIsa("default", _tcache
),
122 encode_coeff(0), encode_tbls(0)
128 ~ErasureCodeIsaDefault() override
133 void isa_encode(char **data
,
135 int blocksize
) override
;
137 virtual bool erasure_contains(int *erasures
, int i
);
139 int isa_decode(int *erasures
,
142 int blocksize
) override
;
144 unsigned get_alignment() const override
;
146 void prepare() override
;
149 int parse(ErasureCodeProfile
&profile
,
150 std::ostream
*ss
) override
;