Skip to content

Commit

Permalink
Merge pull request ceph#1477 from dachary/wip-erasure-code-profiles
Browse files Browse the repository at this point in the history
replace properties with erasure code profiles

Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Mar 17, 2014
2 parents fa1d957 + eac224a commit 27ed656
Show file tree
Hide file tree
Showing 34 changed files with 1,030 additions and 365 deletions.
73 changes: 62 additions & 11 deletions doc/dev/erasure-coded-pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,77 @@ Interface

Set up an erasure coded pool::

ceph osd create ecpool 12 12 erasure
$ ceph osd create ecpool 12 12 erasure

Set up an erasure coded pool and the associated crush ruleset::

ceph osd crush rule create-erasure ecruleset
ceph osd pool create ecpool 12 12 erasure \
crush_ruleset=ecruleset
$ ceph osd crush rule create-erasure ecruleset
$ ceph osd pool create ecpool 12 12 erasure \
default ecruleset

Set the ruleset failure domain to osd instead of the host which is the default::

ceph osd pool create ecpool 12 12 erasure \
erasure-code-ruleset-failure-domain=osd
$ ceph osd erasure-code-profile set myprofile \
ruleset-failure-domain=osd
$ ceph osd erasure-code-profile get myprofile
k=2
m=1
plugin=jerasure
technique=reed_sol_van
ruleset-failure-domain=osd
$ ceph osd pool create ecpool 12 12 erasure myprofile

Control the parameters of the erasure code plugin::

ceph osd pool create ecpool 12 12 erasure \
erasure-code-k=2 erasure-code-m=1
$ ceph osd erasure-code-profile set myprofile \
k=3 m=1
$ ceph osd erasure-code-profile get myprofile
k=3
m=1
plugin=jerasure
technique=reed_sol_van
$ ceph osd pool create ecpool 12 12 erasure \
myprofile

Choose an alternate erasure code plugin::

ceph osd create ecpool 12 12 erasure \
erasure-code-plugin=example

$ ceph osd erasure-code-profile set myprofile \
plugin=example technique=xor
$ ceph osd erasure-code-profile get myprofile
k=2
m=1
plugin=example
technique=xor
$ ceph osd create ecpool 12 12 erasure \
myprofile

Display the default erasure code profile::

$ ceph osd erasure-code-profile ls
default
$ ceph osd erasure-code-profile get default
k=2
m=1
plugin=jerasure
technique=reed_sol_van

Create a profile to set the data to be distributed on six OSDs (k+m=6) and sustain the loss of three OSDs (m=3) without loosing data::

$ ceph osd erasure-code-profile set myprofile k=3 m=3
$ ceph osd erasure-code-profile get myprofile
k=3
m=3
plugin=jerasure
technique=reed_sol_van
$ ceph osd erasure-code-profile ls
default
myprofile

Remove a profile that is no longer in use (otherwise it will fail with EBUSY)::

$ ceph osd erasure-code-profile ls
default
myprofile
$ ceph osd erasure-code-profile rm myprofile
$ ceph osd erasure-code-profile ls
default
3 changes: 1 addition & 2 deletions qa/workunits/cephtool/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ ceph osd pool set data size $new_size
ceph osd pool get data size | grep "size: $new_size"
ceph osd pool set data size $old_size

ceph osd crush rule create-erasure ec_ruleset
ceph osd pool create pool_erasure 12 12 erasure crush_ruleset=ec_ruleset
ceph osd pool create pool_erasure 12 12 erasure
set +e
ceph osd pool set pool_erasure size 4444 2>$TMPFILE
check_response 'not change the size'
Expand Down
3 changes: 2 additions & 1 deletion src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ noinst_HEADERS += \

# important; libmsg before libauth!
LIBCOMMON_DEPS += \
$(LIBERASURE_CODE) \
$(LIBMSG) $(LIBAUTH) \
$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
$(KEYUTILS_LIB)
$(KEYUTILS_LIB)

if LINUX
LIBCOMMON_DEPS += -lrt
Expand Down
10 changes: 5 additions & 5 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ OPTION(osd_pool_default_min_size, OPT_INT, 0) // 0 means no specific default; c
OPTION(osd_pool_default_pg_num, OPT_INT, 8) // number of PGs for new pools. Configure in global or mon section of ceph.conf
OPTION(osd_pool_default_pgp_num, OPT_INT, 8) // number of PGs for placement purposes. Should be equal to pg_num
OPTION(osd_pool_default_erasure_code_directory, OPT_STR, CEPH_PKGLIBDIR"/erasure-code") // default for the erasure-code-directory=XXX property of osd pool create
OPTION(osd_pool_default_erasure_code_properties,
OPTION(osd_pool_default_erasure_code_profile,
OPT_STR,
"erasure-code-plugin=jerasure "
"erasure-code-technique=reed_sol_van "
"erasure-code-k=4 "
"erasure-code-m=2 "
"plugin=jerasure "
"technique=reed_sol_van "
"k=2 "
"m=1 "
) // default properties of osd pool create
OPTION(osd_pool_default_flags, OPT_INT, 0) // default flags for new pools
OPTION(osd_pool_default_flag_hashpspool, OPT_BOOL, true) // use new pg hashing to prevent pool/pg overlap
Expand Down
45 changes: 17 additions & 28 deletions src/erasure-code/ErasureCodePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 Cloudwatt <[email protected]>
* Copyright (C) 2013,2014 Cloudwatt <[email protected]>
*
* Author: Loic Dachary <[email protected]>
*
Expand All @@ -14,21 +14,11 @@
*
*/

#include "common/debug.h"

#include <errno.h>
#include <dlfcn.h>

#include "ErasureCodePlugin.h"

#define dout_subsys ceph_subsys_osd
#undef dout_prefix
#define dout_prefix _prefix(_dout)

static ostream& _prefix(std::ostream* _dout)
{
return *_dout << "ErasureCodePlugin: ";
}

#define PLUGIN_PREFIX "libec_"
#define PLUGIN_SUFFIX ".so"
#define PLUGIN_INIT_FUNCTION "__erasure_code_init"
Expand Down Expand Up @@ -75,14 +65,15 @@ ErasureCodePlugin *ErasureCodePluginRegistry::get(const std::string &name)

int ErasureCodePluginRegistry::factory(const std::string &plugin_name,
const map<std::string,std::string> &parameters,
ErasureCodeInterfaceRef *erasure_code)
ErasureCodeInterfaceRef *erasure_code,
ostream &ss)
{
Mutex::Locker l(lock);
ErasureCodePlugin *plugin = get(plugin_name);
if (plugin == 0) {
int r = 0;
loading = true;
r = load(plugin_name, parameters, &plugin);
r = load(plugin_name, parameters, &plugin, ss);
loading = false;
if (r != 0)
return r;
Expand All @@ -93,18 +84,16 @@ int ErasureCodePluginRegistry::factory(const std::string &plugin_name,

int ErasureCodePluginRegistry::load(const std::string &plugin_name,
const map<std::string,std::string> &parameters,
ErasureCodePlugin **plugin)
ErasureCodePlugin **plugin,
ostream &ss)
{
assert(parameters.count("erasure-code-directory") != 0);
std::string fname = parameters.find("erasure-code-directory")->second
assert(parameters.count("directory") != 0);
std::string fname = parameters.find("directory")->second
+ "/" PLUGIN_PREFIX
+ plugin_name + PLUGIN_SUFFIX;
dout(10) << "load " << plugin_name << " from " << fname << dendl;

void *library = dlopen(fname.c_str(), RTLD_NOW);
if (!library) {
derr << "load dlopen(" << fname
<< "): " << dlerror() << dendl;
ss << "load dlopen(" << fname << "): " << dlerror();
return -EIO;
}

Expand All @@ -114,23 +103,23 @@ int ErasureCodePluginRegistry::load(const std::string &plugin_name,
std::string name = plugin_name;
int r = erasure_code_init(name.c_str());
if (r != 0) {
derr << "erasure_code_init(" << plugin_name
<< "): " << strerror(-r) << dendl;
ss << "erasure_code_init(" << plugin_name
<< "): " << strerror(-r);
dlclose(library);
return r;
}
} else {
derr << "load dlsym(" << fname
<< ", " << PLUGIN_INIT_FUNCTION
<< "): " << dlerror() << dendl;
ss << "load dlsym(" << fname
<< ", " << PLUGIN_INIT_FUNCTION
<< "): " << dlerror();
dlclose(library);
return -ENOENT;
}

*plugin = get(plugin_name);
if (*plugin == 0) {
derr << "load " << PLUGIN_INIT_FUNCTION << "()"
<< "did not register " << plugin_name << dendl;
ss << "load " << PLUGIN_INIT_FUNCTION << "()"
<< "did not register " << plugin_name;
dlclose(library);
return -EBADF;
}
Expand Down
8 changes: 5 additions & 3 deletions src/erasure-code/ErasureCodePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 Cloudwatt <[email protected]>
* Copyright (C) 2013,2014 Cloudwatt <[email protected]>
*
* Author: Loic Dachary <[email protected]>
*
Expand Down Expand Up @@ -56,14 +56,16 @@ namespace ceph {

int factory(const std::string &plugin,
const map<std::string,std::string> &parameters,
ErasureCodeInterfaceRef *erasure_code);
ErasureCodeInterfaceRef *erasure_code,
ostream &ss);

int add(const std::string &name, ErasureCodePlugin *plugin);
ErasureCodePlugin *get(const std::string &name);

int load(const std::string &plugin_name,
const map<std::string,std::string> &parameters,
ErasureCodePlugin **plugin);
ErasureCodePlugin **plugin,
ostream &ss);

};
}
Expand Down
3 changes: 1 addition & 2 deletions src/erasure-code/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ include erasure-code/jerasure/Makefile.am

liberasure_code_la_SOURCES = \
erasure-code/ErasureCodePlugin.cc
liberasure_code_la_LIBADD = $(LIBOSDC) $(LIBOS)
if LINUX
liberasure_code_la_LIBADD += -ldl
liberasure_code_la_LIBADD = -ldl
endif # LINUX
noinst_LTLIBRARIES += liberasure_code.la

Expand Down
36 changes: 18 additions & 18 deletions src/erasure-code/jerasure/ErasureCodeJerasure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 Cloudwatt <[email protected]>
* Copyright (C) 2013,2014 Cloudwatt <[email protected]>
*
* Author: Loic Dachary <[email protected]>
*
Expand Down Expand Up @@ -50,10 +50,10 @@ void ErasureCodeJerasure::init(const map<string,string> &parameters)
{
dout(10) << "technique=" << technique << dendl;
map<string,string>::const_iterator parameter;
parameter = parameters.find("erasure-code-ruleset-root");
parameter = parameters.find("ruleset-root");
if (parameter != parameters.end())
ruleset_root = parameter->second;
parameter = parameters.find("erasure-code-ruleset-failure-domain");
parameter = parameters.find("ruleset-failure-domain");
if (parameter != parameters.end())
ruleset_failure_domain = parameter->second;
parse(parameters);
Expand Down Expand Up @@ -248,9 +248,9 @@ unsigned ErasureCodeJerasureReedSolomonVandermonde::get_alignment() const

void ErasureCodeJerasureReedSolomonVandermonde::parse(const map<std::string,std::string> &parameters)
{
k = to_int("erasure-code-k", parameters, DEFAULT_K);
m = to_int("erasure-code-m", parameters, DEFAULT_M);
w = to_int("erasure-code-w", parameters, DEFAULT_W);
k = to_int("k", parameters, DEFAULT_K);
m = to_int("m", parameters, DEFAULT_M);
w = to_int("w", parameters, DEFAULT_W);
if (w != 8 && w != 16 && w != 32) {
derr << "ReedSolomonVandermonde: w=" << w
<< " must be one of {8, 16, 32} : revert to 8 " << dendl;
Expand Down Expand Up @@ -291,9 +291,9 @@ unsigned ErasureCodeJerasureReedSolomonRAID6::get_alignment() const

void ErasureCodeJerasureReedSolomonRAID6::parse(const map<std::string,std::string> &parameters)
{
k = to_int("erasure-code-k", parameters, DEFAULT_K);
k = to_int("k", parameters, DEFAULT_K);
m = 2;
w = to_int("erasure-code-w", parameters, DEFAULT_W);
w = to_int("w", parameters, DEFAULT_W);
if (w != 8 && w != 16 && w != 32) {
derr << "ReedSolomonRAID6: w=" << w
<< " must be one of {8, 16, 32} : revert to 8 " << dendl;
Expand Down Expand Up @@ -336,10 +336,10 @@ unsigned ErasureCodeJerasureCauchy::get_alignment() const

void ErasureCodeJerasureCauchy::parse(const map<std::string,std::string> &parameters)
{
k = to_int("erasure-code-k", parameters, DEFAULT_K);
m = to_int("erasure-code-m", parameters, DEFAULT_M);
w = to_int("erasure-code-w", parameters, DEFAULT_W);
packetsize = to_int("erasure-code-packetsize", parameters, DEFAULT_PACKETSIZE);
k = to_int("k", parameters, DEFAULT_K);
m = to_int("m", parameters, DEFAULT_M);
w = to_int("w", parameters, DEFAULT_W);
packetsize = to_int("packetsize", parameters, DEFAULT_PACKETSIZE);
}

void ErasureCodeJerasureCauchy::prepare_schedule(int *matrix)
Expand Down Expand Up @@ -406,10 +406,10 @@ unsigned ErasureCodeJerasureLiberation::get_alignment() const

void ErasureCodeJerasureLiberation::parse(const map<std::string,std::string> &parameters)
{
k = to_int("erasure-code-k", parameters, DEFAULT_K);
m = to_int("erasure-code-m", parameters, DEFAULT_M);
w = to_int("erasure-code-w", parameters, DEFAULT_W);
packetsize = to_int("erasure-code-packetsize", parameters, DEFAULT_PACKETSIZE);
k = to_int("k", parameters, DEFAULT_K);
m = to_int("m", parameters, DEFAULT_M);
w = to_int("w", parameters, DEFAULT_W);
packetsize = to_int("packetsize", parameters, DEFAULT_PACKETSIZE);

bool error = false;
if (k > w) {
Expand Down Expand Up @@ -458,10 +458,10 @@ void ErasureCodeJerasureBlaumRoth::prepare()
//
void ErasureCodeJerasureLiber8tion::parse(const map<std::string,std::string> &parameters)
{
k = to_int("erasure-code-k", parameters, DEFAULT_K);
k = to_int("k", parameters, DEFAULT_K);
m = DEFAULT_M;
w = DEFAULT_W;
packetsize = to_int("erasure-code-packetsize", parameters, DEFAULT_PACKETSIZE);
packetsize = to_int("packetsize", parameters, DEFAULT_PACKETSIZE);

bool error = false;
if (k > w) {
Expand Down
6 changes: 3 additions & 3 deletions src/erasure-code/jerasure/ErasureCodePluginJerasure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 Cloudwatt <[email protected]>
* Copyright (C) 2013,2014 Cloudwatt <[email protected]>
*
* Author: Loic Dachary <[email protected]>
*
Expand Down Expand Up @@ -33,8 +33,8 @@ class ErasureCodePluginJerasure : public ErasureCodePlugin {
ErasureCodeInterfaceRef *erasure_code) {
ErasureCodeJerasure *interface;
std::string t;
if (parameters.find("erasure-code-technique") != parameters.end())
t = parameters.find("erasure-code-technique")->second;
if (parameters.find("technique") != parameters.end())
t = parameters.find("technique")->second;
if (t == "reed_sol_van") {
interface = new ErasureCodeJerasureReedSolomonVandermonde();
} else if (t == "reed_sol_r6_op") {
Expand Down
2 changes: 1 addition & 1 deletion src/mon/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ libmon_la_SOURCES = \
mon/HealthMonitor.cc \
mon/DataHealthService.cc \
mon/ConfigKeyService.cc
libmon_la_LIBADD = $(LIBAUTH) $(LIBCOMMON) $(LIBOS) $(LIBERASURE_CODE)
libmon_la_LIBADD = $(LIBAUTH) $(LIBCOMMON) $(LIBOS)
noinst_LTLIBRARIES += libmon.la

noinst_HEADERS += \
Expand Down
Loading

0 comments on commit 27ed656

Please sign in to comment.