diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 05842ee6b78..e259b28feed 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -417,7 +417,7 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap, f->dump_string("error", "syntax error: 'perf reset '"); } 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 '"); } 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 '"); + f->dump_string("error", "syntax error: 'config get '"); } 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 '"); - } - 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> diff; set 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()), diff --git a/src/common/config.cc b/src/common/config.cc index 5703e962392..32a817deb8c 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -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; - } } } } diff --git a/src/common/config.h b/src/common/config.h index caabc46b81d..887b2f7e939 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -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 > *diff, set *unknown);