1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 FUJITSU LIMITED
7 * Copyright (C) 2013, 2014 Cloudwatt <libre.licensing@cloudwatt.com>
8 * Copyright (C) 2014 Red Hat <contact@redhat.com>
10 * Author: Takanori Nakao <nakao.takanori@jp.fujitsu.com>
11 * Author: Takeshi Miyamae <miyamae.takeshi@jp.fujitsu.com>
12 * Author: Loic Dachary <loic@dachary.org>
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
21 #ifndef CEPH_ERASURE_CODE_SHEC_H
22 #define CEPH_ERASURE_CODE_SHEC_H
24 #include "erasure-code/ErasureCode.h"
25 #include "ErasureCodeShecTableCache.h"
27 class ErasureCodeShec
: public ErasureCode
{
35 ErasureCodeShecTableCache
&tcache
;
47 ErasureCodeShec(const int _technique
,
48 ErasureCodeShecTableCache
&_tcache
) :
58 technique(_technique
),
62 ~ErasureCodeShec() override
{}
64 unsigned int get_chunk_count() const override
{
68 unsigned int get_data_chunk_count() const override
{
72 unsigned int get_chunk_size(unsigned int object_size
) const override
;
74 int minimum_to_decode(const set
<int> &want_to_read
,
75 const set
<int> &available_chunks
,
76 set
<int> *minimum
) override
;
78 int minimum_to_decode_with_cost(const set
<int> &want_to_read
,
79 const map
<int, int> &available
,
80 set
<int> *minimum
) override
;
82 int encode(const set
<int> &want_to_encode
,
84 map
<int, bufferlist
> *encoded
) override
;
85 int encode_chunks(const set
<int> &want_to_encode
,
86 map
<int, bufferlist
> *encoded
) override
;
88 int decode(const set
<int> &want_to_read
,
89 const map
<int, bufferlist
> &chunks
,
90 map
<int, bufferlist
> *decoded
) override
;
91 int decode_chunks(const set
<int> &want_to_read
,
92 const map
<int, bufferlist
> &chunks
,
93 map
<int, bufferlist
> *decoded
) override
;
95 int init(ErasureCodeProfile
&profile
, ostream
*ss
) override
;
96 virtual void shec_encode(char **data
,
99 virtual int shec_decode(int *erasures
,
104 virtual unsigned get_alignment() const = 0;
105 virtual void prepare() = 0;
107 virtual int shec_matrix_decode(int *erased
, int *avails
,
108 char **data_ptrs
, char **coding_ptrs
, int size
);
109 virtual int* shec_reedsolomon_coding_matrix(int is_single
);
112 virtual int parse(const ErasureCodeProfile
&profile
) = 0;
114 virtual double shec_calc_recovery_efficiency1(int k
, int m1
, int m2
, int c1
, int c2
);
115 virtual int shec_make_decoding_matrix(bool prepare
,
116 int *want
, int *avails
,
117 int *decoding_matrix
,
118 int *dm_row
, int *dm_column
,
122 class ErasureCodeShecReedSolomonVandermonde
: public ErasureCodeShec
{
125 ErasureCodeShecReedSolomonVandermonde(ErasureCodeShecTableCache
&_tcache
,
126 int technique
= MULTIPLE
) :
127 ErasureCodeShec(technique
, _tcache
)
130 ~ErasureCodeShecReedSolomonVandermonde() override
{
133 void shec_encode(char **data
,
135 int blocksize
) override
;
136 int shec_decode(int *erasures
,
140 int blocksize
) override
;
141 unsigned get_alignment() const override
;
142 void prepare() override
;
144 int parse(const ErasureCodeProfile
&profile
) override
;