From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/erasure-code/ErasureCode.h | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/erasure-code/ErasureCode.h (limited to 'src/erasure-code/ErasureCode.h') diff --git a/src/erasure-code/ErasureCode.h b/src/erasure-code/ErasureCode.h new file mode 100644 index 000000000..c246d5dc6 --- /dev/null +++ b/src/erasure-code/ErasureCode.h @@ -0,0 +1,125 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt + * + * Author: Loic Dachary + * + * 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_H +#define CEPH_ERASURE_CODE_H + +/*! @file ErasureCode.h + @brief Base class for erasure code plugins implementors + + */ + +#include "ErasureCodeInterface.h" + +namespace ceph { + + class ErasureCode : public ErasureCodeInterface { + public: + static const unsigned SIMD_ALIGN; + + std::vector chunk_mapping; + ErasureCodeProfile _profile; + + // for CRUSH rule + std::string rule_root; + std::string rule_failure_domain; + std::string rule_device_class; + + ~ErasureCode() override {} + + int init(ceph::ErasureCodeProfile &profile, std::ostream *ss) override; + + const ErasureCodeProfile &get_profile() const override { + return _profile; + } + + int create_rule(const std::string &name, + CrushWrapper &crush, + std::ostream *ss) const override; + + int sanity_check_k_m(int k, int m, std::ostream *ss); + + unsigned int get_coding_chunk_count() const override { + return get_chunk_count() - get_data_chunk_count(); + } + + virtual int get_sub_chunk_count() override { + return 1; + } + + virtual int _minimum_to_decode(const std::set &want_to_read, + const std::set &available_chunks, + std::set *minimum); + + int minimum_to_decode(const std::set &want_to_read, + const std::set &available, + std::map>> *minimum) override; + + int minimum_to_decode_with_cost(const std::set &want_to_read, + const std::map &available, + std::set *minimum) override; + + int encode_prepare(const bufferlist &raw, + std::map &encoded) const; + + int encode(const std::set &want_to_encode, + const bufferlist &in, + std::map *encoded) override; + + int decode(const std::set &want_to_read, + const std::map &chunks, + std::map *decoded, int chunk_size) override; + + virtual int _decode(const std::set &want_to_read, + const std::map &chunks, + std::map *decoded); + + const std::vector &get_chunk_mapping() const override; + + int to_mapping(const ErasureCodeProfile &profile, + std::ostream *ss); + + static int to_int(const std::string &name, + ErasureCodeProfile &profile, + int *value, + const std::string &default_value, + std::ostream *ss); + + static int to_bool(const std::string &name, + ErasureCodeProfile &profile, + bool *value, + const std::string &default_value, + std::ostream *ss); + + static int to_string(const std::string &name, + ErasureCodeProfile &profile, + std::string *value, + const std::string &default_value, + std::ostream *ss); + + int decode_concat(const std::map &chunks, + bufferlist *decoded) override; + + protected: + int parse(const ErasureCodeProfile &profile, + std::ostream *ss); + + private: + int chunk_index(unsigned int i) const; + }; +} + +#endif -- cgit v1.2.3