From 6caac92c7e561c1d40e78fa1d248b4c4afd60d87 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 2 Feb 2014 09:51:50 +0100 Subject: [PATCH] mon: pool creation helper for size The size of the replicated pools are by default set to osd_pool_default_size but it may vary depending on the pool type. Create a helper to compute the pool size. http://tracker.ceph.com/issues/7277 refs #7277 Reviewed-By: Christophe Courtaut Signed-off-by: Loic Dachary --- src/mon/OSDMonitor.cc | 23 ++++++++++++++++++++++- src/mon/OSDMonitor.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4992e6df6f2a6..8545457db4398 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2774,6 +2774,23 @@ int OSDMonitor::prepare_pool_properties(const unsigned pool_type, return 0; } +int OSDMonitor::prepare_pool_size(const unsigned pool_type, + const map &properties, + unsigned *size, + stringstream &ss) +{ + int err = 0; + switch (pool_type) { + case pg_pool_t::TYPE_REPLICATED: + *size = g_conf->osd_pool_default_size; + break; + default: + ss << "prepare_pool_size: " << pool_type << " is not a known pool type"; + err = -EINVAL; + break; + } + return err; +} /** * @param name The name of the new pool * @param auid The auid of the pool owner. Can be -1 @@ -2805,6 +2822,10 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, return -EINVAL; } } + unsigned size; + r = prepare_pool_size(pool_type, properties_map, &size, ss); + if (r) + return r; for (map::iterator p = pending_inc.new_pool_names.begin(); p != pending_inc.new_pool_names.end(); @@ -2823,7 +2844,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, if (g_conf->osd_pool_default_flag_hashpspool) pi->flags |= pg_pool_t::FLAG_HASHPSPOOL; - pi->size = g_conf->osd_pool_default_size; + pi->size = size; pi->min_size = g_conf->get_osd_pool_default_min_size(); pi->crush_ruleset = crush_ruleset; pi->object_hash = CEPH_STR_HASH_RJENKINS; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index cabd680f53180..2b16234994322 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -240,6 +240,10 @@ private: const vector &properties, map *properties_map, stringstream &ss); + int prepare_pool_size(const unsigned pool_type, + const map &properties, + unsigned *size, + stringstream &ss); int prepare_new_pool(string& name, uint64_t auid, int crush_ruleset, unsigned pg_num, unsigned pgp_num, const vector &properties, -- 2.39.5