mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
erasure-code: optimize header file dependency
Signed-off-by: Xiaowei Chen <chen.xiaowei@h3c.com>
This commit is contained in:
parent
1eef465074
commit
99f27c39b0
@ -16,14 +16,15 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
|
||||
#include "ErasureCode.h"
|
||||
|
||||
#include "common/strtol.h"
|
||||
#include "ErasureCode.h"
|
||||
#include "include/buffer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned ErasureCode::SIMD_ALIGN = 32;
|
||||
|
||||
int ErasureCode::sanity_check_k(int k, ostream *ss)
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ErasureCodeInterface.h"
|
||||
|
||||
namespace ceph {
|
||||
@ -32,12 +30,12 @@ namespace ceph {
|
||||
public:
|
||||
static const unsigned SIMD_ALIGN;
|
||||
|
||||
vector<int> chunk_mapping;
|
||||
std::vector<int> chunk_mapping;
|
||||
ErasureCodeProfile _profile;
|
||||
|
||||
~ErasureCode() override {}
|
||||
|
||||
int init(ErasureCodeProfile &profile, ostream *ss) override {
|
||||
int init(ErasureCodeProfile &profile, std::ostream *ss) override {
|
||||
_profile = profile;
|
||||
return 0;
|
||||
}
|
||||
@ -46,67 +44,67 @@ namespace ceph {
|
||||
return _profile;
|
||||
}
|
||||
|
||||
int sanity_check_k(int k, ostream *ss);
|
||||
int sanity_check_k(int k, std::ostream *ss);
|
||||
|
||||
unsigned int get_coding_chunk_count() const override {
|
||||
return get_chunk_count() - get_data_chunk_count();
|
||||
}
|
||||
|
||||
int minimum_to_decode(const set<int> &want_to_read,
|
||||
const set<int> &available_chunks,
|
||||
set<int> *minimum) override;
|
||||
int minimum_to_decode(const std::set<int> &want_to_read,
|
||||
const std::set<int> &available_chunks,
|
||||
std::set<int> *minimum) override;
|
||||
|
||||
int minimum_to_decode_with_cost(const set<int> &want_to_read,
|
||||
const map<int, int> &available,
|
||||
set<int> *minimum) override;
|
||||
int minimum_to_decode_with_cost(const std::set<int> &want_to_read,
|
||||
const std::map<int, int> &available,
|
||||
std::set<int> *minimum) override;
|
||||
|
||||
int encode_prepare(const bufferlist &raw,
|
||||
map<int, bufferlist> &encoded) const;
|
||||
std::map<int, bufferlist> &encoded) const;
|
||||
|
||||
int encode(const set<int> &want_to_encode,
|
||||
int encode(const std::set<int> &want_to_encode,
|
||||
const bufferlist &in,
|
||||
map<int, bufferlist> *encoded) override;
|
||||
std::map<int, bufferlist> *encoded) override;
|
||||
|
||||
int encode_chunks(const set<int> &want_to_encode,
|
||||
map<int, bufferlist> *encoded) override;
|
||||
int encode_chunks(const std::set<int> &want_to_encode,
|
||||
std::map<int, bufferlist> *encoded) override;
|
||||
|
||||
int decode(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) 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 decode_chunks(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) override;
|
||||
|
||||
const vector<int> &get_chunk_mapping() const override;
|
||||
const std::vector<int> &get_chunk_mapping() const override;
|
||||
|
||||
int to_mapping(const ErasureCodeProfile &profile,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
static int to_int(const std::string &name,
|
||||
ErasureCodeProfile &profile,
|
||||
int *value,
|
||||
const std::string &default_value,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
static int to_bool(const std::string &name,
|
||||
ErasureCodeProfile &profile,
|
||||
bool *value,
|
||||
const std::string &default_value,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
static int to_string(const std::string &name,
|
||||
ErasureCodeProfile &profile,
|
||||
std::string *value,
|
||||
const std::string &default_value,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
int decode_concat(const map<int, bufferlist> &chunks,
|
||||
int decode_concat(const std::map<int, bufferlist> &chunks,
|
||||
bufferlist *decoded) override;
|
||||
|
||||
protected:
|
||||
int parse(const ErasureCodeProfile &profile,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
private:
|
||||
int chunk_index(unsigned int i) const;
|
||||
|
@ -143,19 +143,18 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "include/memory.h"
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "include/buffer_fwd.h"
|
||||
|
||||
class CrushWrapper;
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ceph {
|
||||
|
||||
typedef map<std::string,std::string> ErasureCodeProfile;
|
||||
typedef std::map<std::string,std::string> ErasureCodeProfile;
|
||||
|
||||
inline ostream& operator<<(ostream& out, const ErasureCodeProfile& profile) {
|
||||
inline std::ostream& operator<<(std::ostream& out, const ErasureCodeProfile& profile) {
|
||||
out << "{";
|
||||
for (ErasureCodeProfile::const_iterator it = profile.begin();
|
||||
it != profile.end();
|
||||
@ -186,7 +185,7 @@ namespace ceph {
|
||||
* @param [out] ss contains informative messages when an error occurs
|
||||
* @return 0 on success or a negative errno on error.
|
||||
*/
|
||||
virtual int init(ErasureCodeProfile &profile, ostream *ss) = 0;
|
||||
virtual int init(ErasureCodeProfile &profile, std::ostream *ss) = 0;
|
||||
|
||||
/**
|
||||
* Return the profile that was used to initialize the instance
|
||||
@ -210,9 +209,9 @@ namespace ceph {
|
||||
* @param [out] ss contains informative messages when an error occurs
|
||||
* @return a ruleset on success or a negative errno on error.
|
||||
*/
|
||||
virtual int create_ruleset(const string &name,
|
||||
virtual int create_ruleset(const std::string &name,
|
||||
CrushWrapper &crush,
|
||||
ostream *ss) const = 0;
|
||||
std::ostream *ss) const = 0;
|
||||
|
||||
/**
|
||||
* Return the number of chunks created by a call to the **encode**
|
||||
@ -284,9 +283,9 @@ namespace ceph {
|
||||
* @param [out] minimum chunk indexes to retrieve
|
||||
* @return **0** on success or a negative errno on error.
|
||||
*/
|
||||
virtual int minimum_to_decode(const set<int> &want_to_read,
|
||||
const set<int> &available,
|
||||
set<int> *minimum) = 0;
|
||||
virtual int minimum_to_decode(const std::set<int> &want_to_read,
|
||||
const std::set<int> &available,
|
||||
std::set<int> *minimum) = 0;
|
||||
|
||||
/**
|
||||
* Compute the smallest subset of **available** chunks that needs
|
||||
@ -312,9 +311,9 @@ namespace ceph {
|
||||
* @param [out] minimum chunk indexes to retrieve
|
||||
* @return **0** on success or a negative errno on error.
|
||||
*/
|
||||
virtual int minimum_to_decode_with_cost(const set<int> &want_to_read,
|
||||
const map<int, int> &available,
|
||||
set<int> *minimum) = 0;
|
||||
virtual int minimum_to_decode_with_cost(const std::set<int> &want_to_read,
|
||||
const std::map<int, int> &available,
|
||||
std::set<int> *minimum) = 0;
|
||||
|
||||
/**
|
||||
* Encode the content of **in** and store the result in
|
||||
@ -351,13 +350,13 @@ namespace ceph {
|
||||
* @param [out] encoded map chunk indexes to chunk data
|
||||
* @return **0** on success or a negative errno on error.
|
||||
*/
|
||||
virtual int encode(const set<int> &want_to_encode,
|
||||
virtual int encode(const std::set<int> &want_to_encode,
|
||||
const bufferlist &in,
|
||||
map<int, bufferlist> *encoded) = 0;
|
||||
std::map<int, bufferlist> *encoded) = 0;
|
||||
|
||||
|
||||
virtual int encode_chunks(const set<int> &want_to_encode,
|
||||
map<int, bufferlist> *encoded) = 0;
|
||||
virtual int encode_chunks(const std::set<int> &want_to_encode,
|
||||
std::map<int, bufferlist> *encoded) = 0;
|
||||
|
||||
/**
|
||||
* Decode the **chunks** and store at least **want_to_read**
|
||||
@ -392,13 +391,13 @@ namespace ceph {
|
||||
* @param [out] decoded map chunk indexes to chunk data
|
||||
* @return **0** on success or a negative errno on error.
|
||||
*/
|
||||
virtual int decode(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) = 0;
|
||||
virtual int decode(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) = 0;
|
||||
|
||||
virtual int decode_chunks(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) = 0;
|
||||
virtual int decode_chunks(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) = 0;
|
||||
|
||||
/**
|
||||
* Return the ordered list of chunks or an empty vector
|
||||
@ -433,7 +432,7 @@ namespace ceph {
|
||||
*
|
||||
* @return vector<int> list of indices of chunks to be remapped
|
||||
*/
|
||||
virtual const vector<int> &get_chunk_mapping() const = 0;
|
||||
virtual const std::vector<int> &get_chunk_mapping() const = 0;
|
||||
|
||||
/**
|
||||
* Decode the first **get_data_chunk_count()** **chunks** and
|
||||
@ -445,11 +444,11 @@ namespace ceph {
|
||||
* @param [out] decoded concatenante of the data chunks
|
||||
* @return **0** on success or a negative errno on error.
|
||||
*/
|
||||
virtual int decode_concat(const map<int, bufferlist> &chunks,
|
||||
virtual int decode_concat(const std::map<int, bufferlist> &chunks,
|
||||
bufferlist *decoded) = 0;
|
||||
};
|
||||
|
||||
typedef ceph::shared_ptr<ErasureCodeInterface> ErasureCodeInterfaceRef;
|
||||
typedef std::shared_ptr<ErasureCodeInterface> ErasureCodeInterfaceRef;
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "common/errno.h"
|
||||
#include "include/str_list.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define PLUGIN_PREFIX "libec_"
|
||||
#if defined(DARWIN)
|
||||
#define PLUGIN_SUFFIX ".dylib"
|
||||
|
@ -39,7 +39,7 @@ namespace ceph {
|
||||
virtual int factory(const std::string &directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss) = 0;
|
||||
std::ostream *ss) = 0;
|
||||
};
|
||||
|
||||
class ErasureCodePluginRegistry {
|
||||
@ -62,7 +62,7 @@ namespace ceph {
|
||||
const std::string &directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
int add(const std::string &name, ErasureCodePlugin *plugin);
|
||||
int remove(const std::string &name);
|
||||
@ -71,11 +71,11 @@ namespace ceph {
|
||||
int load(const std::string &plugin_name,
|
||||
const std::string &directory,
|
||||
ErasureCodePlugin **plugin,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
int preload(const std::string &plugins,
|
||||
const std::string &directory,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#include <algorithm>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "common/debug.h"
|
||||
@ -22,6 +21,8 @@
|
||||
#include "xor_op.h"
|
||||
#include "crush/CrushWrapper.h"
|
||||
#include "osd/osd_types.h"
|
||||
using namespace std;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
extern "C" {
|
||||
#include "isa-l/include/erasure_code.h"
|
||||
|
@ -26,12 +26,9 @@
|
||||
#define CEPH_ERASURE_CODE_ISA_L_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "common/Mutex.h"
|
||||
#include "erasure-code/ErasureCode.h"
|
||||
#include "ErasureCodeIsaTableCache.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
#include <list>
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define DEFAULT_RULESET_ROOT "default"
|
||||
#define DEFAULT_RULESET_FAILURE_DOMAIN "host"
|
||||
@ -49,8 +46,8 @@ public:
|
||||
|
||||
ErasureCodeIsaTableCache &tcache;
|
||||
const char *technique;
|
||||
string ruleset_root;
|
||||
string ruleset_failure_domain;
|
||||
std::string ruleset_root;
|
||||
std::string ruleset_failure_domain;
|
||||
|
||||
ErasureCodeIsa(const char *_technique,
|
||||
ErasureCodeIsaTableCache &_tcache) :
|
||||
@ -69,9 +66,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
int create_ruleset(const string &name,
|
||||
int create_ruleset(const std::string &name,
|
||||
CrushWrapper &crush,
|
||||
ostream *ss) const override;
|
||||
std::ostream *ss) const override;
|
||||
|
||||
unsigned int
|
||||
get_chunk_count() const override
|
||||
@ -87,14 +84,14 @@ public:
|
||||
|
||||
unsigned int get_chunk_size(unsigned int object_size) const override;
|
||||
|
||||
int encode_chunks(const set<int> &want_to_encode,
|
||||
map<int, bufferlist> *encoded) override;
|
||||
int encode_chunks(const std::set<int> &want_to_encode,
|
||||
std::map<int, bufferlist> *encoded) override;
|
||||
|
||||
int decode_chunks(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) override;
|
||||
int decode_chunks(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) override;
|
||||
|
||||
int init(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int init(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
|
||||
virtual void isa_encode(char **data,
|
||||
char **coding,
|
||||
@ -112,7 +109,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual int parse(ErasureCodeProfile &profile,
|
||||
ostream *ss) = 0;
|
||||
std::ostream *ss) = 0;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -161,7 +158,7 @@ public:
|
||||
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile,
|
||||
ostream *ss) override;
|
||||
std::ostream *ss) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "ErasureCodeIsaTableCache.h"
|
||||
#include "ErasureCodeIsa.h"
|
||||
#include "common/debug.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -25,15 +25,15 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "ceph_ver.h"
|
||||
#include "common/debug.h"
|
||||
#include "ErasureCodePluginIsa.h"
|
||||
#include "ErasureCodeIsaTableCache.h"
|
||||
#include "ErasureCodeIsa.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int ErasureCodePluginIsa::factory(const std::string &directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss)
|
||||
std::ostream *ss)
|
||||
{
|
||||
ErasureCodeIsa *interface;
|
||||
std::string t;
|
||||
|
@ -13,6 +13,7 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "xor_op.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "arch/intel.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -19,6 +19,9 @@
|
||||
#include "ErasureCodeJerasure.h"
|
||||
#include "crush/CrushWrapper.h"
|
||||
#include "osd/osd_types.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
#include "jerasure.h"
|
||||
#include "reed_sol.h"
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
int w;
|
||||
std::string DEFAULT_W;
|
||||
const char *technique;
|
||||
string ruleset_root;
|
||||
string ruleset_failure_domain;
|
||||
std::string ruleset_root;
|
||||
std::string ruleset_failure_domain;
|
||||
bool per_chunk_alignment;
|
||||
|
||||
explicit ErasureCodeJerasure(const char *_technique) :
|
||||
@ -51,9 +51,9 @@ public:
|
||||
|
||||
~ErasureCodeJerasure() override {}
|
||||
|
||||
int create_ruleset(const string &name,
|
||||
int create_ruleset(const std::string &name,
|
||||
CrushWrapper &crush,
|
||||
ostream *ss) const override;
|
||||
std::ostream *ss) const override;
|
||||
|
||||
unsigned int get_chunk_count() const override {
|
||||
return k + m;
|
||||
@ -65,14 +65,14 @@ public:
|
||||
|
||||
unsigned int get_chunk_size(unsigned int object_size) const override;
|
||||
|
||||
int encode_chunks(const set<int> &want_to_encode,
|
||||
map<int, bufferlist> *encoded) override;
|
||||
int encode_chunks(const std::set<int> &want_to_encode,
|
||||
std::map<int, bufferlist> *encoded) override;
|
||||
|
||||
int decode_chunks(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) override;
|
||||
int decode_chunks(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) override;
|
||||
|
||||
int init(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int init(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
|
||||
virtual void jerasure_encode(char **data,
|
||||
char **coding,
|
||||
@ -85,7 +85,7 @@ public:
|
||||
virtual void prepare() = 0;
|
||||
static bool is_prime(int value);
|
||||
protected:
|
||||
virtual int parse(ErasureCodeProfile &profile, ostream *ss);
|
||||
virtual int parse(ErasureCodeProfile &profile, std::ostream *ss);
|
||||
};
|
||||
|
||||
class ErasureCodeJerasureReedSolomonVandermonde : public ErasureCodeJerasure {
|
||||
@ -115,7 +115,7 @@ public:
|
||||
unsigned get_alignment() const override;
|
||||
void prepare() override;
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int parse(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
};
|
||||
|
||||
class ErasureCodeJerasureReedSolomonRAID6 : public ErasureCodeJerasure {
|
||||
@ -144,7 +144,7 @@ public:
|
||||
unsigned get_alignment() const override;
|
||||
void prepare() override;
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int parse(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
};
|
||||
|
||||
#define DEFAULT_PACKETSIZE "2048"
|
||||
@ -182,7 +182,7 @@ public:
|
||||
unsigned get_alignment() const override;
|
||||
void prepare_schedule(int *matrix);
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int parse(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
};
|
||||
|
||||
class ErasureCodeJerasureCauchyOrig : public ErasureCodeJerasureCauchy {
|
||||
@ -229,15 +229,15 @@ public:
|
||||
char **coding,
|
||||
int blocksize) override;
|
||||
unsigned get_alignment() const override;
|
||||
virtual bool check_k(ostream *ss) const;
|
||||
virtual bool check_w(ostream *ss) const;
|
||||
virtual bool check_packetsize_set(ostream *ss) const;
|
||||
virtual bool check_packetsize(ostream *ss) const;
|
||||
virtual bool check_k(std::ostream *ss) const;
|
||||
virtual bool check_w(std::ostream *ss) const;
|
||||
virtual bool check_packetsize_set(std::ostream *ss) const;
|
||||
virtual bool check_packetsize(std::ostream *ss) const;
|
||||
virtual int revert_to_default(ErasureCodeProfile &profile,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
void prepare() override;
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int parse(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
};
|
||||
|
||||
class ErasureCodeJerasureBlaumRoth : public ErasureCodeJerasureLiberation {
|
||||
@ -247,7 +247,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool check_w(ostream *ss) const override;
|
||||
bool check_w(std::ostream *ss) const override;
|
||||
void prepare() override;
|
||||
};
|
||||
|
||||
@ -263,7 +263,7 @@ public:
|
||||
|
||||
void prepare() override;
|
||||
private:
|
||||
int parse(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int parse(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ static ostream& _prefix(std::ostream* _dout)
|
||||
int ErasureCodePluginJerasure::factory(const std::string& directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss) {
|
||||
std::ostream *ss) {
|
||||
ErasureCodeJerasure *interface;
|
||||
std::string t;
|
||||
if (profile.find("technique") != profile.end())
|
||||
|
@ -36,6 +36,8 @@
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout)
|
||||
|
||||
using namespace std;
|
||||
|
||||
static ostream& _prefix(std::ostream* _dout)
|
||||
{
|
||||
return *_dout << "ErasureCodeLrc: ";
|
||||
|
@ -46,33 +46,33 @@
|
||||
|
||||
class ErasureCodeLrc : public ErasureCode {
|
||||
public:
|
||||
static const string DEFAULT_KML;
|
||||
static const std::string DEFAULT_KML;
|
||||
|
||||
struct Layer {
|
||||
explicit Layer(string _chunks_map) : chunks_map(_chunks_map) { }
|
||||
explicit Layer(std::string _chunks_map) : chunks_map(_chunks_map) { }
|
||||
ErasureCodeInterfaceRef erasure_code;
|
||||
vector<int> data;
|
||||
vector<int> coding;
|
||||
vector<int> chunks;
|
||||
set<int> chunks_as_set;
|
||||
string chunks_map;
|
||||
std::vector<int> data;
|
||||
std::vector<int> coding;
|
||||
std::vector<int> chunks;
|
||||
std::set<int> chunks_as_set;
|
||||
std::string chunks_map;
|
||||
ErasureCodeProfile profile;
|
||||
};
|
||||
vector<Layer> layers;
|
||||
string directory;
|
||||
std::vector<Layer> layers;
|
||||
std::string directory;
|
||||
unsigned int chunk_count;
|
||||
unsigned int data_chunk_count;
|
||||
string ruleset_root;
|
||||
std::string ruleset_root;
|
||||
struct Step {
|
||||
Step(string _op, string _type, int _n) :
|
||||
Step(std::string _op, std::string _type, int _n) :
|
||||
op(_op),
|
||||
type(_type),
|
||||
n(_n) {}
|
||||
string op;
|
||||
string type;
|
||||
std::string op;
|
||||
std::string type;
|
||||
int n;
|
||||
};
|
||||
vector<Step> ruleset_steps;
|
||||
std::vector<Step> ruleset_steps;
|
||||
|
||||
explicit ErasureCodeLrc(const std::string &dir)
|
||||
: directory(dir),
|
||||
@ -83,16 +83,16 @@ public:
|
||||
|
||||
~ErasureCodeLrc() override {}
|
||||
|
||||
set<int> get_erasures(const set<int> &need,
|
||||
const set<int> &available) const;
|
||||
std::set<int> get_erasures(const std::set<int> &need,
|
||||
const std::set<int> &available) const;
|
||||
|
||||
int minimum_to_decode(const set<int> &want_to_read,
|
||||
const set<int> &available,
|
||||
set<int> *minimum) override;
|
||||
int minimum_to_decode(const std::set<int> &want_to_read,
|
||||
const std::set<int> &available,
|
||||
std::set<int> *minimum) override;
|
||||
|
||||
int create_ruleset(const string &name,
|
||||
int create_ruleset(const std::string &name,
|
||||
CrushWrapper &crush,
|
||||
ostream *ss) const override;
|
||||
std::ostream *ss) const override;
|
||||
|
||||
unsigned int get_chunk_count() const override {
|
||||
return chunk_count;
|
||||
@ -104,34 +104,34 @@ public:
|
||||
|
||||
unsigned int get_chunk_size(unsigned int object_size) const override;
|
||||
|
||||
int encode_chunks(const set<int> &want_to_encode,
|
||||
map<int, bufferlist> *encoded) override;
|
||||
int encode_chunks(const std::set<int> &want_to_encode,
|
||||
std::map<int, bufferlist> *encoded) override;
|
||||
|
||||
int decode_chunks(const set<int> &want_to_read,
|
||||
const map<int, bufferlist> &chunks,
|
||||
map<int, bufferlist> *decoded) override;
|
||||
int decode_chunks(const std::set<int> &want_to_read,
|
||||
const std::map<int, bufferlist> &chunks,
|
||||
std::map<int, bufferlist> *decoded) override;
|
||||
|
||||
int init(ErasureCodeProfile &profile, ostream *ss) override;
|
||||
int init(ErasureCodeProfile &profile, std::ostream *ss) override;
|
||||
|
||||
virtual int parse(ErasureCodeProfile &profile, ostream *ss);
|
||||
virtual int parse(ErasureCodeProfile &profile, std::ostream *ss);
|
||||
|
||||
int parse_kml(ErasureCodeProfile &profile, ostream *ss);
|
||||
int parse_kml(ErasureCodeProfile &profile, std::ostream *ss);
|
||||
|
||||
int parse_ruleset(ErasureCodeProfile &profile, ostream *ss);
|
||||
int parse_ruleset(ErasureCodeProfile &profile, std::ostream *ss);
|
||||
|
||||
int parse_ruleset_step(string description_string,
|
||||
int parse_ruleset_step(std::string description_string,
|
||||
json_spirit::mArray description,
|
||||
ostream *ss);
|
||||
std::ostream *ss);
|
||||
|
||||
int layers_description(const ErasureCodeProfile &profile,
|
||||
json_spirit::mArray *description,
|
||||
ostream *ss) const;
|
||||
int layers_parse(string description_string,
|
||||
std::ostream *ss) const;
|
||||
int layers_parse(std::string description_string,
|
||||
json_spirit::mArray description,
|
||||
ostream *ss);
|
||||
int layers_init(ostream *ss);
|
||||
int layers_sanity_checks(string description_string,
|
||||
ostream *ss) const;
|
||||
std::ostream *ss);
|
||||
int layers_init(std::ostream *ss);
|
||||
int layers_sanity_checks(std::string description_string,
|
||||
std::ostream *ss) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,9 +20,6 @@
|
||||
#include "ErasureCodePluginLrc.h"
|
||||
#include "ErasureCodeLrc.h"
|
||||
|
||||
// re-include our assert
|
||||
#include "include/assert.h"
|
||||
|
||||
#define dout_subsys ceph_subsys_osd
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout)
|
||||
@ -30,7 +27,7 @@
|
||||
int ErasureCodePluginLrc::factory(const std::string &directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss) {
|
||||
std::ostream *ss) {
|
||||
ErasureCodeLrc *interface;
|
||||
interface = new ErasureCodeLrc(directory);
|
||||
int r = interface->init(profile, ss);
|
||||
|
@ -39,7 +39,7 @@ static ostream& _prefix(std::ostream* _dout)
|
||||
int ErasureCodePluginShec::factory(const std::string &directory,
|
||||
ErasureCodeProfile &profile,
|
||||
ErasureCodeInterfaceRef *erasure_code,
|
||||
ostream *ss) {
|
||||
std::ostream *ss) {
|
||||
ErasureCodeShec *interface;
|
||||
|
||||
if (profile.find("technique") == profile.end())
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "ErasureCodeShec.h"
|
||||
#include "crush/CrushWrapper.h"
|
||||
@ -63,10 +65,10 @@ int ErasureCodeShec::init(ErasureCodeProfile &profile,
|
||||
ostream *ss)
|
||||
{
|
||||
int err = 0;
|
||||
err |= to_string("ruleset-root", profile,
|
||||
err |= ErasureCode::to_string("ruleset-root", profile,
|
||||
&ruleset_root,
|
||||
DEFAULT_RULESET_ROOT, ss);
|
||||
err |= to_string("ruleset-failure-domain", profile,
|
||||
err |= ErasureCode::to_string("ruleset-failure-domain", profile,
|
||||
&ruleset_failure_domain,
|
||||
DEFAULT_RULESET_FAILURE_DOMAIN, ss);
|
||||
err |= parse(profile);
|
||||
|
@ -21,10 +21,8 @@
|
||||
#ifndef CEPH_ERASURE_CODE_SHEC_H
|
||||
#define CEPH_ERASURE_CODE_SHEC_H
|
||||
|
||||
#include "common/Mutex.h"
|
||||
#include "erasure-code/ErasureCode.h"
|
||||
#include "ErasureCodeShecTableCache.h"
|
||||
#include <list>
|
||||
|
||||
#define DEFAULT_RULESET_ROOT "default"
|
||||
#define DEFAULT_RULESET_FAILURE_DOMAIN "host"
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#include "ErasureCodeShecTableCache.h"
|
||||
#include "ErasureCodeShec.h"
|
||||
#include "common/debug.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
using namespace std;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#define dout_context g_ceph_context
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <errno.h>
|
||||
#include "include/encoding.h"
|
||||
#include "ECUtil.h"
|
||||
using namespace std;
|
||||
|
||||
int ECUtil::decode(
|
||||
const stripe_info_t &sinfo,
|
||||
|
@ -15,10 +15,6 @@
|
||||
#ifndef ECUTIL_H
|
||||
#define ECUTIL_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "include/memory.h"
|
||||
#include "erasure-code/ErasureCodeInterface.h"
|
||||
#include "include/buffer_fwd.h"
|
||||
#include "include/assert.h"
|
||||
@ -72,43 +68,43 @@ public:
|
||||
assert(offset % chunk_size == 0);
|
||||
return (offset / chunk_size) * stripe_width;
|
||||
}
|
||||
pair<uint64_t, uint64_t> aligned_offset_len_to_chunk(
|
||||
pair<uint64_t, uint64_t> in) const {
|
||||
return make_pair(
|
||||
std::pair<uint64_t, uint64_t> aligned_offset_len_to_chunk(
|
||||
std::pair<uint64_t, uint64_t> in) const {
|
||||
return std::make_pair(
|
||||
aligned_logical_offset_to_chunk_offset(in.first),
|
||||
aligned_logical_offset_to_chunk_offset(in.second));
|
||||
}
|
||||
pair<uint64_t, uint64_t> offset_len_to_stripe_bounds(
|
||||
pair<uint64_t, uint64_t> in) const {
|
||||
std::pair<uint64_t, uint64_t> offset_len_to_stripe_bounds(
|
||||
std::pair<uint64_t, uint64_t> in) const {
|
||||
uint64_t off = logical_to_prev_stripe_offset(in.first);
|
||||
uint64_t len = logical_to_next_stripe_offset(
|
||||
(in.first - off) + in.second);
|
||||
return make_pair(off, len);
|
||||
return std::make_pair(off, len);
|
||||
}
|
||||
};
|
||||
|
||||
int decode(
|
||||
const stripe_info_t &sinfo,
|
||||
ErasureCodeInterfaceRef &ec_impl,
|
||||
map<int, bufferlist> &to_decode,
|
||||
std::map<int, bufferlist> &to_decode,
|
||||
bufferlist *out);
|
||||
|
||||
int decode(
|
||||
const stripe_info_t &sinfo,
|
||||
ErasureCodeInterfaceRef &ec_impl,
|
||||
map<int, bufferlist> &to_decode,
|
||||
map<int, bufferlist*> &out);
|
||||
std::map<int, bufferlist> &to_decode,
|
||||
std::map<int, bufferlist*> &out);
|
||||
|
||||
int encode(
|
||||
const stripe_info_t &sinfo,
|
||||
ErasureCodeInterfaceRef &ec_impl,
|
||||
bufferlist &in,
|
||||
const set<int> &want,
|
||||
map<int, bufferlist> *out);
|
||||
const std::set<int> &want,
|
||||
std::map<int, bufferlist> *out);
|
||||
|
||||
class HashInfo {
|
||||
uint64_t total_chunk_size = 0;
|
||||
vector<uint32_t> cumulative_shard_hashes;
|
||||
std::vector<uint32_t> cumulative_shard_hashes;
|
||||
|
||||
// purely ephemeral, represents the size once all in-flight ops commit
|
||||
uint64_t projected_total_chunk_size = 0;
|
||||
@ -116,17 +112,17 @@ public:
|
||||
HashInfo() {}
|
||||
explicit HashInfo(unsigned num_chunks) :
|
||||
cumulative_shard_hashes(num_chunks, -1) {}
|
||||
void append(uint64_t old_size, map<int, bufferlist> &to_append);
|
||||
void append(uint64_t old_size, std::map<int, bufferlist> &to_append);
|
||||
void clear() {
|
||||
total_chunk_size = 0;
|
||||
cumulative_shard_hashes = vector<uint32_t>(
|
||||
cumulative_shard_hashes = std::vector<uint32_t>(
|
||||
cumulative_shard_hashes.size(),
|
||||
-1);
|
||||
}
|
||||
void encode(bufferlist &bl) const;
|
||||
void decode(bufferlist::iterator &bl);
|
||||
void dump(Formatter *f) const;
|
||||
static void generate_test_instances(list<HashInfo*>& o);
|
||||
static void generate_test_instances(std::list<HashInfo*>& o);
|
||||
uint32_t get_chunk_hash(int shard) const {
|
||||
assert((unsigned)shard < cumulative_shard_hashes.size());
|
||||
return cumulative_shard_hashes[shard];
|
||||
@ -168,8 +164,8 @@ public:
|
||||
|
||||
typedef ceph::shared_ptr<HashInfo> HashInfoRef;
|
||||
|
||||
bool is_hinfo_key_string(const string &key);
|
||||
const string &get_hinfo_key();
|
||||
bool is_hinfo_key_string(const std::string &key);
|
||||
const std::string &get_hinfo_key();
|
||||
|
||||
}
|
||||
WRITE_CLASS_ENCODER(ECUtil::HashInfo)
|
||||
|
Loading…
Reference in New Issue
Block a user