From df539a7be2b6f1119362a559332381421e2bc065 Mon Sep 17 00:00:00 2001 From: xinxin shu Date: Fri, 19 Jun 2015 02:11:39 +0800 Subject: [PATCH] move pgp_num, pg_num check to prepare_new_pool method Signed-off-by: xinxin shu --- src/mon/OSDMonitor.cc | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6b82975e00c76..49373fd47e932 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4330,8 +4330,17 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, pg_num = g_conf->osd_pool_default_pg_num; if (pgp_num == 0) pgp_num = g_conf->osd_pool_default_pgp_num; - if (pgp_num > pg_num) + if (pg_num > (unsigned)g_conf->mon_max_pool_pg_num) { + *ss << "'pg_num' must be greater than 0 and less than or equal to " + << g_conf->mon_max_pool_pg_num + << " (you may adjust 'mon max pool pg num' for higher values)"; return -ERANGE; + } + if (pgp_num > pg_num) { + *ss << "'pgp_num' must be greater than 0 and lower or equal than 'pg_num'" + << ", which in this case is " << pg_num; + return -ERANGE; + } int r; r = prepare_pool_crush_ruleset(pool_type, erasure_code_profile, crush_ruleset_name, &crush_ruleset, ss); @@ -6256,21 +6265,7 @@ done: int64_t pg_num; int64_t pgp_num; cmd_getval(g_ceph_context, cmdmap, "pg_num", pg_num, int64_t(0)); - if ((pg_num == 0) || (pg_num > g_conf->mon_max_pool_pg_num)) { - ss << "'pg_num' must be greater than 0 and less than or equal to " - << g_conf->mon_max_pool_pg_num - << " (you may adjust 'mon max pool pg num' for higher values)"; - err = -ERANGE; - goto reply; - } - cmd_getval(g_ceph_context, cmdmap, "pgp_num", pgp_num, pg_num); - if ((pgp_num == 0) || (pgp_num > pg_num)) { - ss << "'pgp_num' must be greater than 0 and lower or equal than 'pg_num'" - << ", which in this case is " << pg_num; - err = -ERANGE; - goto reply; - } string pool_type_str; cmd_getval(g_ceph_context, cmdmap, "pool_type", pool_type_str); @@ -6386,6 +6381,8 @@ done: case -EAGAIN: wait_for_finished_proposal(new C_RetryMessage(this, m)); return true; + case -ERANGE: + goto reply; default: goto reply; break; -- 2.39.5