From 54090f180c2cf33a294d1c12c70d002550b79267 Mon Sep 17 00:00:00 2001 From: Guang G Yang Date: Tue, 21 Jul 2015 20:45:48 +0000 Subject: [PATCH] mon: add a configuration for default fast read setting Signed-off-by: Guang Yang --- src/common/config_opts.h | 1 + src/mon/OSDMonitor.cc | 38 ++++++++++++++++++++++++++++++++++++-- src/mon/OSDMonitor.h | 7 +++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 2bfbc581e9624..81d3291f9fc87 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -212,6 +212,7 @@ OPTION(mon_osd_allow_primary_temp, OPT_BOOL, false) // allow primary_temp to be OPTION(mon_osd_allow_primary_affinity, OPT_BOOL, false) // allow primary_affinity to be set in the osdmap OPTION(mon_osd_prime_pg_temp, OPT_BOOL, false) // prime osdmap with pg mapping changes OPTION(mon_osd_prime_pg_temp_max_time, OPT_FLOAT, .5) // max time to spend priming +OPTION(mon_osd_pool_ec_fast_read, OPT_BOOL, false) // whether turn on fast read on the pool or not OPTION(mon_stat_smooth_intervals, OPT_INT, 2) // smooth stats over last N PGMap maps OPTION(mon_lease, OPT_FLOAT, 5) // lease interval OPTION(mon_lease_renew_interval, OPT_FLOAT, 3) // on leader, to renew the lease diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 04ee1a05826d6..f1672e8e935bb 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4039,12 +4039,12 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op) return prepare_new_pool(m->name, m->auid, m->crush_rule, ruleset_name, 0, 0, erasure_code_profile, - pg_pool_t::TYPE_REPLICATED, 0, &ss); + pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss); else return prepare_new_pool(m->name, session->auid, m->crush_rule, ruleset_name, 0, 0, erasure_code_profile, - pg_pool_t::TYPE_REPLICATED, 0, &ss); + pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss); } int OSDMonitor::crush_rename_bucket(const string& srcname, @@ -4428,6 +4428,7 @@ int OSDMonitor::get_crush_ruleset(const string &ruleset_name, * @param erasure_code_profile The profile name in OSDMap to be used for erasure code * @param pool_type TYPE_ERASURE, or TYPE_REP * @param expected_num_objects expected number of objects on the pool + * @param fast_read fast read type. * @param ss human readable error message, if any. * * @return 0 on success, negative errno on failure. @@ -4439,6 +4440,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, const string &erasure_code_profile, const unsigned pool_type, const uint64_t expected_num_objects, + FastReadType fast_read, ostream *ss) { if (name.length() == 0) @@ -4458,6 +4460,10 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, << ", which in this case is " << pg_num; return -ERANGE; } + if (pool_type == pg_pool_t::TYPE_REPLICATED && fast_read == FAST_READ_ON) { + *ss << "'fast_read' can only apply to erasure coding pool"; + return -EINVAL; + } int r; r = prepare_pool_crush_ruleset(pool_type, erasure_code_profile, crush_ruleset_name, &crush_ruleset, ss); @@ -4513,6 +4519,24 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, if (g_conf->osd_pool_use_gmt_hitset && (osdmap.get_up_osd_features() & CEPH_FEATURE_OSD_HITSET_GMT)) pi->use_gmt_hitset = true; + + if (pool_type == pg_pool_t::TYPE_ERASURE) { + switch (fast_read) { + case FAST_READ_OFF: + pi->fast_read = false; + break; + case FAST_READ_ON: + pi->fast_read = true; + break; + case FAST_READ_DEFAULT: + pi->fast_read = g_conf->mon_osd_pool_ec_fast_read; + break; + default: + *ss << "invalid fast_read setting: " << fast_read; + return -EINVAL; + } + } + pi->size = size; pi->min_size = min_size; pi->crush_ruleset = crush_ruleset; @@ -6557,12 +6581,22 @@ done: err = -EINVAL; goto reply; } + + int8_t fast_read_param; + cmd_getval(g_ceph_context, cmdmap, "fast_read", fast_read_param, int8_t(-1)); + FastReadType fast_read = FAST_READ_DEFAULT; + if (fast_read_param == 0) + fast_read = FAST_READ_OFF; + else if (fast_read_param > 0) + fast_read = FAST_READ_ON; + err = prepare_new_pool(poolstr, 0, // auid=0 for admin created pool -1, // default crush rule ruleset_name, pg_num, pgp_num, erasure_code_profile, pool_type, (uint64_t)expected_num_objects, + fast_read, &ss); if (err < 0) { switch(err) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index a185954e11880..78e00f90e5f9c 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -152,6 +152,12 @@ private: CrushWrapper &_get_stable_crush(); void _get_pending_crush(CrushWrapper& newcrush); + enum FastReadType { + FAST_READ_OFF, + FAST_READ_ON, + FAST_READ_DEFAULT + }; + // svc public: void create_initial(); @@ -312,6 +318,7 @@ private: const string &erasure_code_profile, const unsigned pool_type, const uint64_t expected_num_objects, + FastReadType fast_read, ostream *ss); int prepare_new_pool(MonOpRequestRef op); -- 2.39.5