From: Loic Dachary Date: Sat, 1 Feb 2014 09:09:12 +0000 (+0100) Subject: mon: helper for pool properties parsing X-Git-Tag: v0.78~226^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0cac20251acc4c152aaf5bdbba484ecc36ab1168;p=ceph.git mon: helper for pool properties parsing Add the prepare_pool_properties to convert the properties vector into a properties map suitable for either initializing the pg_pool_t member or an erasure code plugin. Reviewed-By: Christophe Courtaut Signed-off-by: Loic Dachary --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c85a88c5f2b2..3614cadb3e10 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2742,6 +2742,38 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m) properties, pg_pool_t::TYPE_REPLICATED, ss); } +int OSDMonitor::prepare_pool_properties(const unsigned pool_type, + const vector &properties, + map *properties_map, + stringstream &ss) +{ + if (pool_type == pg_pool_t::TYPE_ERASURE) { + int r = get_str_map(g_conf->osd_pool_default_erasure_code_properties, + ss, + properties_map); + if (r) + return r; + (*properties_map)["erasure-code-directory"] = + g_conf->osd_pool_default_erasure_code_directory; + } + + for (vector::const_iterator i = properties.begin(); + i != properties.end(); + ++i) { + size_t equal = i->find('='); + if (equal == string::npos) + (*properties_map)[*i] = string(); + else { + const string key = i->substr(0, equal); + equal++; + const string value = i->substr(equal); + (*properties_map)[key] = value; + } + } + + return 0; +} + /** * @param name The name of the new pool * @param auid The auid of the pool owner. Can be -1 @@ -2760,17 +2792,10 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, 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; - } - + map properties_map; + int r = prepare_pool_properties(pool_type, properties, &properties_map, ss); + if (r) + return r; for (map::iterator p = pending_inc.new_pool_names.begin(); p != pending_inc.new_pool_names.end(); ++p) { @@ -2808,20 +2833,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, 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) { - size_t equal = i->find('='); - if (equal == string::npos) - pi->properties[*i] = string(); - else { - const string key = i->substr(0, equal); - equal++; - const string value = i->substr(equal); - pi->properties[key] = value; - } - } + pi->properties = properties_map; pending_inc.new_pool_names[pool] = name; return 0; } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 81ea4320d151..cabd680f5318 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -236,6 +236,10 @@ private: bool prepare_pool_op (MPoolOp *m); bool prepare_pool_op_create (MPoolOp *m); bool prepare_pool_op_delete(MPoolOp *m); + int prepare_pool_properties(const unsigned pool_type, + const vector &properties, + map *properties_map, + stringstream &ss); int prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, unsigned pg_num, unsigned pgp_num, const vector &properties,