Skip to content

Commit

Permalink
src/: drop cct from cmd_getval()
Browse files Browse the repository at this point in the history
it's not used.

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jan 31, 2020
1 parent 90eb673 commit 5d5b0f9
Show file tree
Hide file tree
Showing 24 changed files with 450 additions and 450 deletions.
4 changes: 2 additions & 2 deletions src/common/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ void AdminSocket::execute_command(
}
string prefix;
try {
cmd_getval(m_cct, cmdmap, "format", format);
cmd_getval(m_cct, cmdmap, "prefix", prefix);
cmd_getval(cmdmap, "format", format);
cmd_getval(cmdmap, "prefix", prefix);
} catch (const bad_cmd_get& e) {
return on_finish(-EINVAL, "invalid json, missing format and/or prefix",
empty);
Expand Down
22 changes: 11 additions & 11 deletions src/common/ceph_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ int CephContext::_do_command(
command == "perf dump") {
std::string logger;
std::string counter;
cmd_getval(this, cmdmap, "logger", logger);
cmd_getval(this, cmdmap, "counter", counter);
cmd_getval(cmdmap, "logger", logger);
cmd_getval(cmdmap, "counter", counter);
_perf_counters_collection->dump_formatted(f, false, logger, counter);
}
else if (command == "perfcounters_schema" || command == "2" ||
Expand All @@ -499,8 +499,8 @@ int CephContext::_do_command(
else if (command == "perf histogram dump") {
std::string logger;
std::string counter;
cmd_getval(this, cmdmap, "logger", logger);
cmd_getval(this, cmdmap, "counter", counter);
cmd_getval(cmdmap, "logger", logger);
cmd_getval(cmdmap, "counter", counter);
_perf_counters_collection->dump_formatted_histograms(f, false, logger,
counter);
}
Expand All @@ -511,7 +511,7 @@ int CephContext::_do_command(
std::string var;
std::string section(command);
f->open_object_section(section.c_str());
if (!cmd_getval(this, cmdmap, "var", var)) {
if (!cmd_getval(cmdmap, "var", var)) {
f->dump_string("error", "syntax error: 'perf reset <var>'");
} else {
if(!_perf_counters_collection->reset(var))
Expand All @@ -530,7 +530,7 @@ int CephContext::_do_command(
}
else if (command == "config unset") {
std::string var;
if (!(cmd_getval(this, cmdmap, "var", var))) {
if (!(cmd_getval(cmdmap, "var", var))) {
r = -EINVAL;
} else {
r = _conf.rm_val(var.c_str());
Expand All @@ -548,8 +548,8 @@ int CephContext::_do_command(
std::string var;
std::vector<std::string> val;

if (!(cmd_getval(this, cmdmap, "var", var)) ||
!(cmd_getval(this, cmdmap, "val", val))) {
if (!(cmd_getval(cmdmap, "var", var)) ||
!(cmd_getval(cmdmap, "val", val))) {
r = -EINVAL;
} else {
// val may be multiple words
Expand All @@ -566,7 +566,7 @@ int CephContext::_do_command(
}
} else if (command == "config get") {
std::string var;
if (!cmd_getval(this, cmdmap, "var", var)) {
if (!cmd_getval(cmdmap, "var", var)) {
r = -EINVAL;
} else {
char buf[4096];
Expand All @@ -582,7 +582,7 @@ int CephContext::_do_command(
}
} else if (command == "config help") {
std::string var;
if (cmd_getval(this, cmdmap, "var", var)) {
if (cmd_getval(cmdmap, "var", var)) {
// Output a single one
std::string key = ConfFile::normalize_key_name(var);
auto schema = _conf.get_schema(key);
Expand Down Expand Up @@ -612,7 +612,7 @@ int CephContext::_do_command(
}
else if (command == "injectargs") {
vector<string> argsvec;
cmd_getval(this, cmdmap, "injected_args", argsvec);
cmd_getval(cmdmap, "injected_args", argsvec);
if (!argsvec.empty()) {
string args = joinify<std::string>(argsvec.begin(),
argsvec.end(),
Expand Down
4 changes: 2 additions & 2 deletions src/common/cmdparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ bool validate_arg(CephContext* cct,
{
Value v;
try {
if (!cmd_getval(cct, cmdmap, string(name), v)) {
if (!cmd_getval(cmdmap, string(name), v)) {
if constexpr (is_vector) {
// an empty list is acceptable.
return true;
Expand Down Expand Up @@ -631,7 +631,7 @@ bool validate_cmd(CephContext* cct,
});
}

bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap,
bool cmd_getval(const cmdmap_t& cmdmap,
const std::string& k, bool& val)
{
/*
Expand Down
6 changes: 3 additions & 3 deletions src/common/cmdparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ struct bad_cmd_get : public std::exception {
}
};

bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap,
bool cmd_getval(const cmdmap_t& cmdmap,
const std::string& k, bool& val);

template <typename T>
bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap,
bool cmd_getval(const cmdmap_t& cmdmap,
const std::string& k, T& val)
{
if (cmdmap.count(k)) {
Expand All @@ -78,7 +78,7 @@ bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap,

template <typename T>
bool cmd_getval(
CephContext *cct, const cmdmap_t& cmdmap, const std::string& k,
const cmdmap_t& cmdmap, const std::string& k,
T& val, const T& defval)
{
if (cmdmap.count(k)) {
Expand Down
6 changes: 3 additions & 3 deletions src/mds/MDSDaemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,18 @@ void MDSDaemon::asok_command(
r = -EOPNOTSUPP;
} else {
string heapcmd;
cmd_getval(cct, cmdmap, "heapcmd", heapcmd);
cmd_getval(cmdmap, "heapcmd", heapcmd);
vector<string> heapcmd_vec;
get_str_vec(heapcmd, heapcmd_vec);
string value;
if (cmd_getval(cct, cmdmap, "value", value)) {
if (cmd_getval(cmdmap, "value", value)) {
heapcmd_vec.push_back(value);
}
ceph_heap_profiler_handle_command(heapcmd_vec, ss);
}
} else if (command == "cpu_profiler") {
string arg;
cmd_getval(cct, cmdmap, "arg", arg);
cmd_getval(cmdmap, "arg", arg);
vector<string> argvec;
get_str_vec(arg, argvec);
cpu_profiler_handle_command(argvec, ss);
Expand Down
56 changes: 28 additions & 28 deletions src/mds/MDSRank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ void MDSRankDispatcher::handle_asok_command(
}
} else if (command == "osdmap barrier") {
int64_t target_epoch = 0;
bool got_val = cmd_getval(g_ceph_context, cmdmap, "target_epoch", target_epoch);
bool got_val = cmd_getval(cmdmap, "target_epoch", target_epoch);

if (!got_val) {
ss << "no target epoch given";
Expand All @@ -2470,7 +2470,7 @@ void MDSRankDispatcher::handle_asok_command(
command == "client ls") {
std::lock_guard l(mds_lock);
std::vector<std::string> filter_args;
cmd_getval(g_ceph_context, cmdmap, "filters", filter_args);
cmd_getval(cmdmap, "filters", filter_args);
SessionFilter filter;
r = filter.parse(filter_args, &ss);
if (r != 0) {
Expand All @@ -2481,7 +2481,7 @@ void MDSRankDispatcher::handle_asok_command(
command == "client evict") {
std::lock_guard l(mds_lock);
std::vector<std::string> filter_args;
cmd_getval(g_ceph_context, cmdmap, "filters", filter_args);
cmd_getval(cmdmap, "filters", filter_args);

SessionFilter filter;
r = filter.parse(filter_args, &ss);
Expand All @@ -2493,7 +2493,7 @@ void MDSRankDispatcher::handle_asok_command(
return;
} else if (command == "session kill") {
std::string client_id;
if (!cmd_getval(g_ceph_context, cmdmap, "client_id", client_id)) {
if (!cmd_getval(cmdmap, "client_id", client_id)) {
ss << "Invalid client_id specified";
r = -ENOENT;
goto out;
Expand All @@ -2511,9 +2511,9 @@ void MDSRankDispatcher::handle_asok_command(
std::string option;
std::string value;

cmd_getval(g_ceph_context, cmdmap, "client_id", client_id);
cmd_getval(g_ceph_context, cmdmap, "option", option);
bool got_value = cmd_getval(g_ceph_context, cmdmap, "value", value);
cmd_getval(cmdmap, "client_id", client_id);
cmd_getval(cmdmap, "option", option);
bool got_value = cmd_getval(cmdmap, "value", value);

std::lock_guard l(mds_lock);
r = config_client(client_id, !got_value, option, value, ss);
Expand All @@ -2522,9 +2522,9 @@ void MDSRankDispatcher::handle_asok_command(
string path;
string tag;
vector<string> scrubop_vec;
cmd_getval(g_ceph_context, cmdmap, "scrubops", scrubop_vec);
cmd_getval(g_ceph_context, cmdmap, "path", path);
cmd_getval(g_ceph_context, cmdmap, "tag", tag);
cmd_getval(cmdmap, "scrubops", scrubop_vec);
cmd_getval(cmdmap, "path", path);
cmd_getval(cmdmap, "tag", tag);

/* Multiple MDS scrub is not currently supported. See also: https://tracker.ceph.com/issues/12274 */
if (mdsmap->get_max_mds() > 1) {
Expand Down Expand Up @@ -2583,27 +2583,27 @@ void MDSRankDispatcher::handle_asok_command(
command_scrub_status(f);
} else if (command == "tag path") {
string path;
cmd_getval(g_ceph_context, cmdmap, "path", path);
cmd_getval(cmdmap, "path", path);
string tag;
cmd_getval(g_ceph_context, cmdmap, "tag", tag);
cmd_getval(cmdmap, "tag", tag);
command_tag_path(f, path, tag);
} else if (command == "flush_path") {
string path;
cmd_getval(g_ceph_context, cmdmap, "path", path);
cmd_getval(cmdmap, "path", path);
command_flush_path(f, path);
} else if (command == "flush journal") {
command_flush_journal(f);
} else if (command == "get subtrees") {
command_get_subtrees(f);
} else if (command == "export dir") {
string path;
if(!cmd_getval(g_ceph_context, cmdmap, "path", path)) {
if(!cmd_getval(cmdmap, "path", path)) {
ss << "malformed path";
r = -EINVAL;
goto out;
}
int64_t rank;
if(!cmd_getval(g_ceph_context, cmdmap, "rank", rank)) {
if(!cmd_getval(cmdmap, "rank", rank)) {
ss << "malformed rank";
r = -EINVAL;
goto out;
Expand All @@ -2612,14 +2612,14 @@ void MDSRankDispatcher::handle_asok_command(
} else if (command == "dump cache") {
std::lock_guard l(mds_lock);
string path;
if (!cmd_getval(g_ceph_context, cmdmap, "path", path)) {
if (!cmd_getval(cmdmap, "path", path)) {
r = mdcache->dump_cache(f);
} else {
r = mdcache->dump_cache(path);
}
} else if (command == "cache drop") {
int64_t timeout = 0;
cmd_getval(g_ceph_context, cmdmap, "timeout", timeout);
cmd_getval(cmdmap, "timeout", timeout);
finisher->queue(
new LambdaContext(
[this, on_finish, f, timeout](int r) {
Expand All @@ -2643,7 +2643,7 @@ void MDSRankDispatcher::handle_asok_command(
} else if (command == "dump snaps") {
std::lock_guard l(mds_lock);
string server;
cmd_getval(g_ceph_context, cmdmap, "server", server);
cmd_getval(cmdmap, "server", server);
if (server == "--server") {
if (mdsmap->get_tableserver() == whoami) {
snapserver->dump(f);
Expand Down Expand Up @@ -2673,7 +2673,7 @@ void MDSRankDispatcher::handle_asok_command(
} else if (command == "damage rm") {
std::lock_guard l(mds_lock);
damage_entry_id_t id = 0;
if (!cmd_getval(g_ceph_context, cmdmap, "damage_id", (int64_t&)id)) {
if (!cmd_getval(cmdmap, "damage_id", (int64_t&)id)) {
r = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -2909,8 +2909,8 @@ void MDSRank::command_dump_tree(const cmdmap_t &cmdmap, std::ostream &ss, Format
{
std::string root;
int64_t depth;
cmd_getval(g_ceph_context, cmdmap, "root", root);
if (!cmd_getval(g_ceph_context, cmdmap, "depth", depth))
cmd_getval(cmdmap, "root", root);
if (!cmd_getval(cmdmap, "depth", depth))
depth = -1;
std::lock_guard l(mds_lock);
CInode *in = mdcache->cache_traverse(filepath(root.c_str()));
Expand All @@ -2928,14 +2928,14 @@ CDir *MDSRank::_command_dirfrag_get(
std::ostream &ss)
{
std::string path;
bool got = cmd_getval(g_ceph_context, cmdmap, "path", path);
bool got = cmd_getval(cmdmap, "path", path);
if (!got) {
ss << "missing path argument";
return NULL;
}

std::string frag_str;
if (!cmd_getval(g_ceph_context, cmdmap, "frag", frag_str)) {
if (!cmd_getval(cmdmap, "frag", frag_str)) {
ss << "missing frag argument";
return NULL;
}
Expand Down Expand Up @@ -2978,7 +2978,7 @@ bool MDSRank::command_dirfrag_split(
{
std::lock_guard l(mds_lock);
int64_t by = 0;
if (!cmd_getval(g_ceph_context, cmdmap, "bits", by)) {
if (!cmd_getval(cmdmap, "bits", by)) {
ss << "missing bits argument";
return false;
}
Expand All @@ -3004,14 +3004,14 @@ bool MDSRank::command_dirfrag_merge(
{
std::lock_guard l(mds_lock);
std::string path;
bool got = cmd_getval(g_ceph_context, cmdmap, "path", path);
bool got = cmd_getval(cmdmap, "path", path);
if (!got) {
ss << "missing path argument";
return false;
}

std::string frag_str;
if (!cmd_getval(g_ceph_context, cmdmap, "frag", frag_str)) {
if (!cmd_getval(cmdmap, "frag", frag_str)) {
ss << "missing frag argument";
return false;
}
Expand Down Expand Up @@ -3040,7 +3040,7 @@ bool MDSRank::command_dirfrag_ls(
{
std::lock_guard l(mds_lock);
std::string path;
bool got = cmd_getval(g_ceph_context, cmdmap, "path", path);
bool got = cmd_getval(cmdmap, "path", path);
if (!got) {
ss << "missing path argument";
return false;
Expand Down Expand Up @@ -3081,7 +3081,7 @@ void MDSRank::command_dump_inode(Formatter *f, const cmdmap_t &cmdmap, std::ostr
{
std::lock_guard l(mds_lock);
int64_t number;
bool got = cmd_getval(g_ceph_context, cmdmap, "number", number);
bool got = cmd_getval(cmdmap, "number", number);
if (!got) {
ss << "missing inode number";
return;
Expand Down
2 changes: 1 addition & 1 deletion src/mgr/ClusterState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ bool ClusterState::asok_command(
if (admin_command == "dump_osd_network") {
int64_t value = 0;
// Default to health warning level if nothing specified
if (!(cmd_getval(g_ceph_context, cmdmap, "value", value))) {
if (!(cmd_getval(cmdmap, "value", value))) {
// Convert milliseconds to microseconds
value = static_cast<int64_t>(g_ceph_context->_conf.get_val<double>("mon_warn_on_slow_ping_time")) * 1000;
if (value == 0) {
Expand Down
Loading

0 comments on commit 5d5b0f9

Please sign in to comment.