From ac14d4ffae25d00a9c3f7fd139ec409f330870f9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 23 Dec 2013 15:18:07 -0800 Subject: [PATCH] osdc/Objecter: maintain crush_location multimap Observe and parse the 'crush location' config option. Signed-off-by: Sage Weil --- src/osdc/Objecter.cc | 30 ++++++++++++++++++++++++++++++ src/osdc/Objecter.h | 11 +++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index d6f3499c7a3..09a508bc730 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -44,6 +44,7 @@ #include "common/config.h" #include "common/perf_counters.h" +#include "include/str_list.h" #define dout_subsys ceph_subsys_objecter @@ -127,6 +128,35 @@ enum { }; +// config obs ---------------------------- + +static const char *config_keys[] = { + "crush_location", + NULL +}; + +const char** Objecter::get_tracked_conf_keys() const +{ + return config_keys; +} + + +void Objecter::handle_conf_change(const struct md_config_t *conf, + const std::set &changed) +{ + if (changed.count("crush_location")) { + crush_location.clear(); + vector lvec; + get_str_vec(cct->_conf->crush_location, lvec); + int r = CrushWrapper::parse_loc_multimap(lvec, &crush_location); + if (r < 0) { + lderr(cct) << "warning: crush_location '" << cct->_conf->crush_location + << "' does not parse" << dendl; + } + } +} + + // messages ------------------------------ void Objecter::init_unlocked() diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 228a744b0cb..6e218458aa0 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -916,12 +916,19 @@ struct ObjectOperation { // ---------------- -class Objecter { - public: +class Objecter : public md_config_obs_t { +public: + // config observer bits + virtual const char** get_tracked_conf_keys() const; + virtual void handle_conf_change(const struct md_config_t *conf, + const std::set &changed); + +public: Messenger *messenger; MonClient *monc; OSDMap *osdmap; CephContext *cct; + std::multimap crush_location; bool initialized;