summaryrefslogtreecommitdiffstats
path: root/src/erasure-code/shec/ErasureCodeShec.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/erasure-code/shec/ErasureCodeShec.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/erasure-code/shec/ErasureCodeShec.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/erasure-code/shec/ErasureCodeShec.h b/src/erasure-code/shec/ErasureCodeShec.h
new file mode 100644
index 00000000..b53eb538
--- /dev/null
+++ b/src/erasure-code/shec/ErasureCodeShec.h
@@ -0,0 +1,147 @@
+// -*- 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) 2013, 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
+ *
+ * Author: Takanori Nakao <nakao.takanori@jp.fujitsu.com>
+ * Author: Takeshi Miyamae <miyamae.takeshi@jp.fujitsu.com>
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ * 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.
+ *
+ */
+
+#ifndef CEPH_ERASURE_CODE_SHEC_H
+#define CEPH_ERASURE_CODE_SHEC_H
+
+#include "erasure-code/ErasureCode.h"
+#include "ErasureCodeShecTableCache.h"
+
+class ErasureCodeShec : public ErasureCode {
+
+public:
+ enum {
+ MULTIPLE = 0,
+ SINGLE = 1
+ };
+
+ ErasureCodeShecTableCache &tcache;
+ int k;
+ int DEFAULT_K;
+ int m;
+ int DEFAULT_M;
+ int c;
+ int DEFAULT_C;
+ int w;
+ int DEFAULT_W;
+ int technique;
+ int *matrix;
+
+ ErasureCodeShec(const int _technique,
+ ErasureCodeShecTableCache &_tcache) :
+ tcache(_tcache),
+ k(0),
+ DEFAULT_K(4),
+ m(0),
+ DEFAULT_M(3),
+ c(0),
+ DEFAULT_C(2),
+ w(0),
+ DEFAULT_W(8),
+ technique(_technique),
+ matrix(0)
+ {}
+
+ ~ErasureCodeShec() override {}
+
+ unsigned int get_chunk_count() const override {
+ return k + m;
+ }
+
+ unsigned int get_data_chunk_count() const override {
+ return k;
+ }
+
+ unsigned int get_chunk_size(unsigned int object_size) const override;
+
+ int _minimum_to_decode(const std::set<int> &want_to_read,
+ const std::set<int> &available_chunks,
+ std::set<int> *minimum);
+
+ int minimum_to_decode_with_cost(const set<int> &want_to_read,
+ const map<int, int> &available,
+ set<int> *minimum) override;
+
+ int encode(const set<int> &want_to_encode,
+ const bufferlist &in,
+ map<int, bufferlist> *encoded) override;
+ int encode_chunks(const set<int> &want_to_encode,
+ map<int, bufferlist> *encoded) override;
+
+ int _decode(const std::set<int> &want_to_read,
+ const std::map<int, bufferlist> &chunks,
+ std::map<int, bufferlist> *decoded) override;
+ int decode_chunks(const set<int> &want_to_read,
+ const map<int, bufferlist> &chunks,
+ map<int, bufferlist> *decoded) override;
+
+ int init(ErasureCodeProfile &profile, ostream *ss) override;
+ virtual void shec_encode(char **data,
+ char **coding,
+ int blocksize) = 0;
+ virtual int shec_decode(int *erasures,
+ int *avails,
+ char **data,
+ char **coding,
+ 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 *want, int *avails,
+ int *decoding_matrix,
+ int *dm_row, int *dm_column,
+ int *minimum);
+};
+
+class ErasureCodeShecReedSolomonVandermonde final : public ErasureCodeShec {
+public:
+
+ ErasureCodeShecReedSolomonVandermonde(ErasureCodeShecTableCache &_tcache,
+ int technique = MULTIPLE) :
+ ErasureCodeShec(technique, _tcache)
+ {}
+
+ ~ErasureCodeShecReedSolomonVandermonde() override {
+ }
+
+ void shec_encode(char **data,
+ char **coding,
+ int blocksize) override;
+ int shec_decode(int *erasures,
+ int *avails,
+ char **data,
+ char **coding,
+ int blocksize) override;
+ unsigned get_alignment() const override;
+ void prepare() override;
+private:
+ int parse(const ErasureCodeProfile &profile) override;
+};
+
+#endif