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 #define DEFAULT_RULESET_ROOT "default"
28 #define DEFAULT_RULESET_FAILURE_DOMAIN "host"
30 class ErasureCodeShec
: public ErasureCode
{
38 ErasureCodeShecTableCache
&tcache
;
49 string ruleset_failure_domain
;
52 ErasureCodeShec(const int _technique
,
53 ErasureCodeShecTableCache
&_tcache
) :
63 technique(_technique
),
64 ruleset_root(DEFAULT_RULESET_ROOT
),
65 ruleset_failure_domain(DEFAULT_RULESET_FAILURE_DOMAIN
),
69 ~ErasureCodeShec() override
{}
71 int create_ruleset(const string
&name
,
73 ostream
*ss
) const override
;
75 unsigned int get_chunk_count() const override
{
79 unsigned int get_data_chunk_count() const override
{
83 unsigned int get_chunk_size(unsigned int object_size
) const override
;
85 int minimum_to_decode(const set
<int> &want_to_read
,
86 const set
<int> &available_chunks
,
87 set
<int> *minimum
) override
;
89 int minimum_to_decode_with_cost(const set
<int> &want_to_read
,
90 const map
<int, int> &available
,
91 set
<int> *minimum
) override
;
93 int encode(const set
<int> &want_to_encode
,
95 map
<int, bufferlist
> *encoded
) override
;
96 int encode_chunks(const set
<int> &want_to_encode
,
97 map
<int, bufferlist
> *encoded
) override
;
99 int decode(const set
<int> &want_to_read
,
100 const map
<int, bufferlist
> &chunks
,
101 map
<int, bufferlist
> *decoded
) override
;
102 int decode_chunks(const set
<int> &want_to_read
,
103 const map
<int, bufferlist
> &chunks
,
104 map
<int, bufferlist
> *decoded
) override
;
106 int init(ErasureCodeProfile
&profile
, ostream
*ss
) override
;
107 virtual void shec_encode(char **data
,
110 virtual int shec_decode(int *erasures
,
115 virtual unsigned get_alignment() const = 0;
116 virtual void prepare() = 0;
118 virtual int shec_matrix_decode(int *erased
, int *avails
,
119 char **data_ptrs
, char **coding_ptrs
, int size
);
120 virtual int* shec_reedsolomon_coding_matrix(int is_single
);
123 virtual int parse(const ErasureCodeProfile
&profile
) = 0;
125 virtual double shec_calc_recovery_efficiency1(int k
, int m1
, int m2
, int c1
, int c2
);
126 virtual int shec_make_decoding_matrix(bool prepare
,
127 int *want
, int *avails
,
128 int *decoding_matrix
,
129 int *dm_row
, int *dm_column
,
133 class ErasureCodeShecReedSolomonVandermonde
: public ErasureCodeShec
{
136 ErasureCodeShecReedSolomonVandermonde(ErasureCodeShecTableCache
&_tcache
,
137 int technique
= MULTIPLE
) :
138 ErasureCodeShec(technique
, _tcache
)
141 ~ErasureCodeShecReedSolomonVandermonde() override
{
144 void shec_encode(char **data
,
146 int blocksize
) override
;
147 int shec_decode(int *erasures
,
151 int blocksize
) override
;
152 unsigned get_alignment() const override
;
153 void prepare() override
;
155 int parse(const ErasureCodeProfile
&profile
) override
;