]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/MgrClient: only send config_bl if it has changed
authorSage Weil <sage@redhat.com>
Fri, 2 Feb 2018 17:29:21 +0000 (11:29 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:50 +0000 (14:44 -0600)
The mgr already treats the config_bl as optional in the MMgrReport
messages.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config.cc
src/common/config.h
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index 0bb9ae37c6467e00d05f94009ee7fdd0d6f5bfbc..b1b5861e36d05fbbc13893df8522d8b2ad9ac636 100644 (file)
@@ -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
index 390efa1ae58442cf088372b30108eb59ef3310a0..01db98cbaef98aa9358dc96e78e7173646cf3d72 100644 (file)
@@ -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<string,string>)
   bufferlist defaults_bl;
 
@@ -190,7 +193,9 @@ public:
   int rm_val(const std::string& key);
 
   /// get encoded map<string,map<int32_t,string>> 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<string,string> of compiled-in defaults
   void get_defaults_bl(bufferlist *bl);
index 7f50258b771c7dd6dc53696a49efffddd0ceae75..25b0eea2cc8c4ca9affedea2e5fb8ae9832ea5ec 100644 (file)
@@ -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);
 }
index a3493f5c6642bd254dfca95075e5968d0e5e8dac..0f4d3c32e69f9a817e9688fc9b5d735ae0cf40a9 100644 (file)
@@ -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;