]> git.proxmox.com Git - ceph.git/blame - ceph/src/erasure-code/ErasureCode.h
add subtree-ish sources for 12.0.3
[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
25#include <vector>
26
27#include "ErasureCodeInterface.h"
28
29namespace ceph {
30
31 class ErasureCode : public ErasureCodeInterface {
32 public:
33 static const unsigned SIMD_ALIGN;
34
35 vector<int> chunk_mapping;
36 ErasureCodeProfile _profile;
37
38 ~ErasureCode() override {}
39
40 int init(ErasureCodeProfile &profile, ostream *ss) override {
41 _profile = profile;
42 return 0;
43 }
44
45 const ErasureCodeProfile &get_profile() const override {
46 return _profile;
47 }
48
49 int sanity_check_k(int k, ostream *ss);
50
51 unsigned int get_coding_chunk_count() const override {
52 return get_chunk_count() - get_data_chunk_count();
53 }
54
55 int minimum_to_decode(const set<int> &want_to_read,
56 const set<int> &available_chunks,
57 set<int> *minimum) override;
58
59 int minimum_to_decode_with_cost(const set<int> &want_to_read,
60 const map<int, int> &available,
61 set<int> *minimum) override;
62
63 int encode_prepare(const bufferlist &raw,
64 map<int, bufferlist> &encoded) const;
65
66 int encode(const set<int> &want_to_encode,
67 const bufferlist &in,
68 map<int, bufferlist> *encoded) override;
69
70 int encode_chunks(const set<int> &want_to_encode,
71 map<int, bufferlist> *encoded) override;
72
73 int decode(const set<int> &want_to_read,
74 const map<int, bufferlist> &chunks,
75 map<int, bufferlist> *decoded) override;
76
77 int decode_chunks(const set<int> &want_to_read,
78 const map<int, bufferlist> &chunks,
79 map<int, bufferlist> *decoded) override;
80
81 const vector<int> &get_chunk_mapping() const override;
82
83 int to_mapping(const ErasureCodeProfile &profile,
84 ostream *ss);
85
86 static int to_int(const std::string &name,
87 ErasureCodeProfile &profile,
88 int *value,
89 const std::string &default_value,
90 ostream *ss);
91
92 static int to_bool(const std::string &name,
93 ErasureCodeProfile &profile,
94 bool *value,
95 const std::string &default_value,
96 ostream *ss);
97
98 static int to_string(const std::string &name,
99 ErasureCodeProfile &profile,
100 std::string *value,
101 const std::string &default_value,
102 ostream *ss);
103
104 int decode_concat(const map<int, bufferlist> &chunks,
105 bufferlist *decoded) override;
106
107 protected:
108 int parse(const ErasureCodeProfile &profile,
109 ostream *ss);
110
111 private:
112 int chunk_index(unsigned int i) const;
113 };
114}
115
116#endif