From: Sage Weil Date: Fri, 2 Feb 2018 17:29:21 +0000 (-0600) Subject: mgr/MgrClient: only send config_bl if it has changed X-Git-Tag: v13.0.2~78^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8e2a30068accd74c4bb452852375e7e94e00c50b;p=ceph.git mgr/MgrClient: only send config_bl if it has changed The mgr already treats the config_bl as optional in the MMgrReport messages. Signed-off-by: Sage Weil --- diff --git a/src/common/config.cc b/src/common/config.cc index 0bb9ae37c646..b1b5861e36d0 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -916,7 +916,10 @@ void md_config_t::get_defaults_bl(bufferlist *bl) *bl = defaults_bl; } -void md_config_t::get_config_bl(bufferlist *bl) +void md_config_t::get_config_bl( + uint64_t have_version, + bufferlist *bl, + uint64_t *got_version) { Mutex::Locker l(lock); if (values_bl.length() == 0) { @@ -959,8 +962,12 @@ void md_config_t::get_config_bl(bufferlist *bl) encode(n, values_bl); values_bl.claim_append(bl); encode(ignored_mon_values, values_bl); + ++values_bl_version; + } + if (have_version != values_bl_version) { + *bl = values_bl; + *got_version = values_bl_version; } - *bl = values_bl; } int md_config_t::get_val(const std::string &key, char **buf, int len) const diff --git a/src/common/config.h b/src/common/config.h index 390efa1ae584..01db98cbaef9 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -110,6 +110,9 @@ public: /// encoded, cached copy of of values + ignored_mon_values bufferlist values_bl; + /// version for values_bl; increments each time there is a change + uint64_t values_bl_version = 0; + /// encoded copy of defaults (map) bufferlist defaults_bl; @@ -190,7 +193,9 @@ public: int rm_val(const std::string& key); /// get encoded map> of entire config - void get_config_bl(bufferlist *bl); + void get_config_bl(uint64_t have_version, + bufferlist *bl, + uint64_t *got_version); /// get encoded map of compiled-in defaults void get_defaults_bl(bufferlist *bl); diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 7f50258b771c..25b0eea2cc8c 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -174,7 +174,7 @@ void MgrClient::_send_open() open->service_daemon = service_daemon; open->daemon_metadata = daemon_metadata; } - cct->_conf->get_config_bl(&open->config_bl); + cct->_conf->get_config_bl(0, &open->config_bl, &last_config_bl_version); cct->_conf->get_defaults_bl(&open->config_defaults_bl); session->con->send_message(open); } @@ -331,7 +331,8 @@ void MgrClient::send_report() report->osd_health_metrics = std::move(osd_health_metrics); - cct->_conf->get_config_bl(&report->config_bl); + cct->_conf->get_config_bl(last_config_bl_version, &report->config_bl, + &last_config_bl_version); session->con->send_message(report); } diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index a3493f5c6642..0f4d3c32e69f 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -66,6 +66,8 @@ protected: utime_t last_connect_attempt; + uint64_t last_config_bl_version = 0; + Context *report_callback = nullptr; Context *connect_retry_callback = nullptr;