From 59941b10f178610f7fea8a86b2ddc179186266db Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 22 Dec 2013 23:37:08 +0100 Subject: [PATCH] mon: erasure code pool properties defaults If no properties are set when creating an erasure coded pool, default to using the jerasure plugin with the cauchy_good technique which is the fastest. The defaults are set with osd_pool_default_erasure_code_properties. The erasure code plugins are loaded from the directory specified in the erasure-code-directory property. Contrary to the other properties it will most commonly be the same throughout the cluster. The default is set to /usr/lib/ceph/erasure-code with osd_pool_default_erasure_code_directory Signed-off-by: Loic Dachary --- src/common/config_opts.h | 9 +++++++++ src/mon/OSDMonitor.cc | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 279fdaebd3194..d40da11a7714a 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -397,6 +397,15 @@ OPTION(osd_pool_default_size, OPT_INT, 3) OPTION(osd_pool_default_min_size, OPT_INT, 0) // 0 means no specific default; ceph will use size-size/2 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, + OPT_STR, + "erasure-code-plugin=jerasure " + "erasure-code-technique=cauchy_good " + "erasure-code-packetsize=3072 " + "erasure-code-k=4 " + "erasure-code-m=2 " + ) // 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 OPTION(osd_hit_set_min_size, OPT_INT, 1000) // min target size for a HitSet diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d4c61dc060107..5b49eaf8c15b1 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -50,6 +50,7 @@ #include "include/util.h" #include "common/cmdparse.h" #include "include/str_list.h" +#include "include/str_map.h" #define dout_subsys ceph_subsys_mon #undef dout_prefix @@ -2740,8 +2741,10 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m) * @param pg_num The pg_num to use. If set to 0, will use the system default * @param pgp_num The pgp_num to use. If set to 0, will use the system default * @param properties An opaque list of key[=value] pairs for pool configuration + * @param pool_type TYPE_ERASURE, TYPE_REP or TYPE_RAID4 + * @param ss human readable error message, if any. * - * @return 0 in all cases. That's silly. + * @return 0 on success, negative errno on failure. */ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule, unsigned pg_num, unsigned pgp_num, @@ -2749,6 +2752,17 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule, const unsigned pool_type, stringstream &ss) { + map default_properties; + if (pool_type == pg_pool_t::TYPE_ERASURE) { + int r = get_str_map(g_conf->osd_pool_default_erasure_code_properties, + ss, + &default_properties); + if (r) + return r; + default_properties["erasure-code-directory"] = + g_conf->osd_pool_default_erasure_code_directory; + } + for (map::iterator p = pending_inc.new_pool_names.begin(); p != pending_inc.new_pool_names.end(); ++p) { @@ -2777,6 +2791,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule, pi->set_pgp_num(pgp_num ? pgp_num : g_conf->osd_pool_default_pgp_num); pi->last_change = pending_inc.epoch; pi->auid = auid; + pi->properties = default_properties; for (vector::const_iterator i = properties.begin(); i != properties.end(); ++i) { -- 2.39.5