Skip to content

Commit

Permalink
Merge pull request #15172 from badone/wip-erasure-code-optimize-heade…
Browse files Browse the repository at this point in the history
…r-file-dependency

erasure-code: optimize header file dependency

Reviewed-by: Kefu Chai <kchai@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
yuriw committed May 23, 2017
2 parents aaaf48c + c586df5 commit fea1f93
Show file tree
Hide file tree
Showing 24 changed files with 173 additions and 178 deletions.
7 changes: 4 additions & 3 deletions src/erasure-code/ErasureCode.cc
Expand Up @@ -16,14 +16,15 @@
*/

#include <errno.h>
#include <vector>
#include <algorithm>
#include <ostream>

#include "common/strtol.h"
#include "ErasureCode.h"

#include "common/strtol.h"
#include "include/buffer.h"

using namespace std;

const unsigned ErasureCode::SIMD_ALIGN = 32;

int ErasureCode::sanity_check_k(int k, ostream *ss)
Expand Down
56 changes: 27 additions & 29 deletions src/erasure-code/ErasureCode.h
Expand Up @@ -22,8 +22,6 @@
*/

#include <vector>

#include "ErasureCodeInterface.h"

namespace ceph {
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
55 changes: 27 additions & 28 deletions src/erasure-code/ErasureCodeInterface.h
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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**
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;

}

Expand Down
2 changes: 2 additions & 0 deletions src/erasure-code/ErasureCodePlugin.cc
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/erasure-code/ErasureCodePlugin.h
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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);
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/erasure-code/isa/ErasureCodeIsa.cc
Expand Up @@ -14,14 +14,15 @@

// -----------------------------------------------------------------------------
#include <algorithm>
#include <dlfcn.h>
#include <errno.h>
// -----------------------------------------------------------------------------
#include "common/debug.h"
#include "ErasureCodeIsa.h"
#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"
Expand Down

0 comments on commit fea1f93

Please sign in to comment.