]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Latest Changes based on comments: 10736/head
authoroliveiradan <doliveirabrz@gmail.com>
Mon, 15 May 2017 22:58:39 +0000 (16:58 -0600)
committeroliveiradan <doliveirabrz@gmail.com>
Tue, 16 May 2017 05:02:59 +0000 (23:02 -0600)
https://github.com/ceph/ceph/pull/10736#discussion_r116404207
https://github.com/ceph/ceph/pull/10736#discussion_r116404213
https://github.com/ceph/ceph/pull/10736#discussion_r116404236

Signed-off-by: Daniel Oliveira <doliveira@suse.com>
src/common/ceph_context.cc
src/common/config.cc
src/common/config.h

index 05842ee6b78fe41055488a4b0f98bca3eb941d5d..e259b28feed44290f5ebe258ba7d8c6cdface7de 100644 (file)
@@ -417,7 +417,7 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
       f->dump_string("error", "syntax error: 'perf reset <var>'");
     } else {
      if(!_perf_counters_collection->reset(var))
-       f->dump_stream("error") << "Not find: " << var;
+        f->dump_stream("error") << "Not find: " << var;
      else
        f->dump_string("success", command + ' ' + var);
     }
@@ -438,8 +438,8 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
           !(cmd_getval(this, cmdmap, "val", val))) {
         f->dump_string("error", "syntax error: 'config set <var> <value>'");
       } else {
-       // val may be multiple words
-       string valstr = str_join(val, " ");
+       // val may be multiple words
+       string valstr = str_join(val, " ");
         int r = _conf->set_val(var.c_str(), valstr.c_str());
         if (r < 0) {
           f->dump_stream("error") << "error setting '" << var << "' to '" << valstr << "': " << cpp_strerror(r);
@@ -452,17 +452,17 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
     } else if (command == "config get") {
       std::string var;
       if (!cmd_getval(this, cmdmap, "var", var)) {
-       f->dump_string("error", "syntax error: 'config get <var>'");
+       f->dump_string("error", "syntax error: 'config get <var>'");
       } else {
-       char buf[4096];
-       memset(buf, 0, sizeof(buf));
-       char *tmp = buf;
-       int r = _conf->get_val(var.c_str(), &tmp, sizeof(buf));
-       if (r < 0) {
-         f->dump_stream("error") << "error getting '" << var << "': " << cpp_strerror(r);
-       } else {
-         f->dump_string(var.c_str(), buf);
-       }
+       char buf[4096];
+       memset(buf, 0, sizeof(buf));
+       char *tmp = buf;
+       int r = _conf->get_val(var.c_str(), &tmp, sizeof(buf));
+       if (r < 0) {
+           f->dump_stream("error") << "error getting '" << var << "': " << cpp_strerror(r);
+       } else {
+           f->dump_string(var.c_str(), buf);
+       }
       }
     } else if (command == "config diff") {
       md_config_t def_conf;
@@ -496,13 +496,11 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
         f->dump_string("option", *p);
       }
       f->close_section(); // unknown
-    }
-    else if (command == "config diff get") {
-      std::string ceph_setting;
-      if (!cmd_getval(this, cmdmap, "var", ceph_setting)) {
+    } else if (command == "config diff get") {
+      std::string setting;
+      if (!cmd_getval(this, cmdmap, "var", setting)) {
         f->dump_string("error", "syntax error: 'config diff get <var>'");
-      } 
-      else {
+      } else {
         md_config_t def_conf;
         def_conf.set_val("cluster", _conf->cluster);
         def_conf.name = _conf->name;
@@ -511,7 +509,7 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
 
         map<string, pair<string, string>> diff;
         set<string> unknown;
-        def_conf.diff(_conf, &diff, &unknown, ceph_setting);
+        def_conf.diff(_conf, &diff, &unknown, setting);
         f->open_object_section("diff");
         f->open_object_section("current");
 
@@ -526,9 +524,8 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
         } 
         f->close_section();   //-- defaults
         f->close_section();   //-- diff
-      } //-- else if (!cmd_getval(this, cmdmap, "var", ceph_setting))
-    } //-- else if (command == "config diff get")
-    else if (command == "log flush") {
+      } 
+    } else if (command == "log flush") {
       _log->flush();
     }
     else if (command == "log dump") {
@@ -548,6 +545,7 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
                         << "result is " << out->length() << " bytes" << dendl;
 }
 
+
 CephContext::CephContext(uint32_t module_type_, int init_flags_)
   : nref(1),
     _conf(new md_config_t()),
index 5703e96239260aa88236615f11169a8371e9ee7c..32a817deb8c9b380b5630aa02fba6a72161ddb8d 100644 (file)
@@ -1377,9 +1377,6 @@ void md_config_t::diff_helper(
     char *other_val = other_buf;
     int err = other->get_val(opt.name, &other_val, sizeof(other_buf));
     if (err < 0) {
-      if (!setting.empty()) {
-        continue;
-      }
       if (err == -ENOENT) {
         unknown->insert(opt.name);
       }
@@ -1393,11 +1390,9 @@ void md_config_t::diff_helper(
 
     if (strcmp(local_val, other_val))
       diff->insert(make_pair(opt.name, make_pair(local_val, other_val)));
-    else {
-      if (!setting.empty()) {
+    else if (!setting.empty()) {
         diff->insert(make_pair(opt.name, make_pair(local_val, other_val)));
         break;
-      }
     }
   }
 }
index caabc46b81dde9ed41c043632eabed2d2997ba85..887b2f7e9398b0304ea771cfd760366f3dae308b 100644 (file)
@@ -235,7 +235,7 @@ public:
   /// dump all config values to a formatter
   void show_config(Formatter *f);
 
-  /// obtain a diff between our config values and another md_config_t values 
+  /// obtain a diff between our config values and another md_config_t values
   void diff(const md_config_t *other,
             map<string,pair<string,string> > *diff, set<string> *unknown);