From d75459351f36b1999277844d9722ed0258902702 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 5 Jan 2018 09:17:45 -0600 Subject: [PATCH] mon/ConfigMonitor: load_config() a bit less often We could get very clever and avoid reparsing the full config every time too, but that is a bit more work. Leave that as a TODO. Signed-off-by: Sage Weil --- src/mon/ConfigMonitor.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index 44ef7d180274e..f6c492002085d 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -40,11 +40,12 @@ void ConfigMonitor::create_initial() void ConfigMonitor::update_from_paxos(bool *need_bootstrap) { + if (version == get_last_committed()) { + return; + } version = get_last_committed(); - dout(10) << __func__ << dendl; + dout(10) << __func__ << " " << version << dendl; load_config(); - -#warning fixme: load changed sections to hint load_config() } void ConfigMonitor::create_pending() @@ -55,17 +56,18 @@ void ConfigMonitor::create_pending() void ConfigMonitor::encode_pending(MonitorDBStore::TransactionRef t) { - ++version; - dout(10) << " " << version << dendl; - put_last_committed(t, version); + dout(10) << " " << (version+1) << dendl; + put_last_committed(t, version+1); -#warning fixme: record changed sections (osd, mds.foo, rack:bar, ...) + // TODO: record changed sections (osd, mds.foo, rack:bar, ...) for (auto& p : pending) { string key = KEY_PREFIX + p.first; if (p.second) { + dout(20) << __func__ << " set " << key << dendl; t->put(CONFIG_PREFIX, key, *p.second); } else { + dout(20) << __func__ << " rm " << key << dendl; t->erase(CONFIG_PREFIX, key); } } @@ -294,7 +296,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) goto reply; } - string key = KEY_PREFIX; + string key; if (section.size()) { key += section + "/"; } @@ -308,9 +310,9 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) if (prefix == "config set") { bufferlist bl; bl.append(value); - t->put(CONFIG_PREFIX, key, bl); + pending[key] = bl; } else { - t->erase(CONFIG_PREFIX, key); + pending[key] = boost::none; } goto update; } else { -- 2.39.5