]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/shec/ErasureCodeShec.h
update sources to v12.1.1
[ceph.git] / ceph / src / erasure-code / shec / ErasureCodeShec.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
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>
9 *
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>
13 *
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.
18 *
19 */
20
21 #ifndef CEPH_ERASURE_CODE_SHEC_H
22 #define CEPH_ERASURE_CODE_SHEC_H
23
24 #include "erasure-code/ErasureCode.h"
25 #include "ErasureCodeShecTableCache.h"
26
27 class ErasureCodeShec : public ErasureCode {
28
29 public:
30 enum {
31 MULTIPLE = 0,
32 SINGLE = 1
33 };
34
35 ErasureCodeShecTableCache &tcache;
36 int k;
37 int DEFAULT_K;
38 int m;
39 int DEFAULT_M;
40 int c;
41 int DEFAULT_C;
42 int w;
43 int DEFAULT_W;
44 int technique;
45 int *matrix;
46
47 ErasureCodeShec(const int _technique,
48 ErasureCodeShecTableCache &_tcache) :
49 tcache(_tcache),
50 k(0),
51 DEFAULT_K(4),
52 m(0),
53 DEFAULT_M(3),
54 c(0),
55 DEFAULT_C(2),
56 w(0),
57 DEFAULT_W(8),
58 technique(_technique),
59 matrix(0)
60 {}
61
62 ~ErasureCodeShec() override {}
63
64 unsigned int get_chunk_count() const override {
65 return k + m;
66 }
67
68 unsigned int get_data_chunk_count() const override {
69 return k;
70 }
71
72 unsigned int get_chunk_size(unsigned int object_size) const override;
73
74 int minimum_to_decode(const set<int> &want_to_read,
75 const set<int> &available_chunks,
76 set<int> *minimum) override;
77
78 int minimum_to_decode_with_cost(const set<int> &want_to_read,
79 const map<int, int> &available,
80 set<int> *minimum) override;
81
82 int encode(const set<int> &want_to_encode,
83 const bufferlist &in,
84 map<int, bufferlist> *encoded) override;
85 int encode_chunks(const set<int> &want_to_encode,
86 map<int, bufferlist> *encoded) override;
87
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;
94
95 int init(ErasureCodeProfile &profile, ostream *ss) override;
96 virtual void shec_encode(char **data,
97 char **coding,
98 int blocksize) = 0;
99 virtual int shec_decode(int *erasures,
100 int *avails,
101 char **data,
102 char **coding,
103 int blocksize) = 0;
104 virtual unsigned get_alignment() const = 0;
105 virtual void prepare() = 0;
106
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);
110
111 private:
112 virtual int parse(const ErasureCodeProfile &profile) = 0;
113
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,
119 int *minimum);
120 };
121
122 class ErasureCodeShecReedSolomonVandermonde : public ErasureCodeShec {
123 public:
124
125 ErasureCodeShecReedSolomonVandermonde(ErasureCodeShecTableCache &_tcache,
126 int technique = MULTIPLE) :
127 ErasureCodeShec(technique, _tcache)
128 {}
129
130 ~ErasureCodeShecReedSolomonVandermonde() override {
131 }
132
133 void shec_encode(char **data,
134 char **coding,
135 int blocksize) override;
136 int shec_decode(int *erasures,
137 int *avails,
138 char **data,
139 char **coding,
140 int blocksize) override;
141 unsigned get_alignment() const override;
142 void prepare() override;
143 private:
144 int parse(const ErasureCodeProfile &profile) override;
145 };
146
147 #endif