]> git.proxmox.com Git - ceph.git/blame - ceph/src/erasure-code/ErasureCode.h
update sources to v12.1.0
[ceph.git] / ceph / src / erasure-code / ErasureCode.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph distributed storage system
5 *
6 * Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
7 *
8 * Author: Loic Dachary <loic@dachary.org>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 */
16
17#ifndef CEPH_ERASURE_CODE_H
18#define CEPH_ERASURE_CODE_H
19
20/*! @file ErasureCode.h
21 @brief Base class for erasure code plugins implementors
22
23 */
24
7c673cae
FG
25#include "ErasureCodeInterface.h"
26
27namespace ceph {
28
29 class ErasureCode : public ErasureCodeInterface {
30 public:
31 static const unsigned SIMD_ALIGN;
32
31f18b77 33 std::vector<int> chunk_mapping;
7c673cae
FG
34 ErasureCodeProfile _profile;
35
36 ~ErasureCode() override {}
37
31f18b77 38 int init(ErasureCodeProfile &profile, std::ostream *ss) override {
7c673cae
FG
39 _profile = profile;
40 return 0;
41 }
42
43 const ErasureCodeProfile &get_profile() const override {
44 return _profile;
45 }
46
31f18b77 47 int sanity_check_k(int k, std::ostream *ss);
7c673cae
FG
48
49 unsigned int get_coding_chunk_count() const override {
50 return get_chunk_count() - get_data_chunk_count();
51 }
52
31f18b77
FG
53 int minimum_to_decode(const std::set<int> &want_to_read,
54 const std::set<int> &available_chunks,
55 std::set<int> *minimum) override;
7c673cae 56
31f18b77
FG
57 int minimum_to_decode_with_cost(const std::set<int> &want_to_read,
58 const std::map<int, int> &available,
59 std::set<int> *minimum) override;
7c673cae
FG
60
61 int encode_prepare(const bufferlist &raw,
31f18b77 62 std::map<int, bufferlist> &encoded) const;
7c673cae 63
31f18b77 64 int encode(const std::set<int> &want_to_encode,
7c673cae 65 const bufferlist &in,
31f18b77 66 std::map<int, bufferlist> *encoded) override;
7c673cae 67
31f18b77
FG
68 int encode_chunks(const std::set<int> &want_to_encode,
69 std::map<int, bufferlist> *encoded) override;
7c673cae 70
31f18b77
FG
71 int decode(const std::set<int> &want_to_read,
72 const std::map<int, bufferlist> &chunks,
73 std::map<int, bufferlist> *decoded) override;
7c673cae 74
31f18b77
FG
75 int decode_chunks(const std::set<int> &want_to_read,
76 const std::map<int, bufferlist> &chunks,
77 std::map<int, bufferlist> *decoded) override;
7c673cae 78
31f18b77 79 const std::vector<int> &get_chunk_mapping() const override;
7c673cae
FG
80
81 int to_mapping(const ErasureCodeProfile &profile,
31f18b77 82 std::ostream *ss);
7c673cae
FG
83
84 static int to_int(const std::string &name,
85 ErasureCodeProfile &profile,
86 int *value,
87 const std::string &default_value,
31f18b77 88 std::ostream *ss);
7c673cae
FG
89
90 static int to_bool(const std::string &name,
91 ErasureCodeProfile &profile,
92 bool *value,
93 const std::string &default_value,
31f18b77 94 std::ostream *ss);
7c673cae
FG
95
96 static int to_string(const std::string &name,
97 ErasureCodeProfile &profile,
98 std::string *value,
99 const std::string &default_value,
31f18b77 100 std::ostream *ss);
7c673cae 101
31f18b77 102 int decode_concat(const std::map<int, bufferlist> &chunks,
7c673cae
FG
103 bufferlist *decoded) override;
104
105 protected:
106 int parse(const ErasureCodeProfile &profile,
31f18b77 107 std::ostream *ss);
7c673cae
FG
108
109 private:
110 int chunk_index(unsigned int i) const;
111 };
112}
113
114#endif