From: Joao Eduardo Luis Date: Wed, 17 Jun 2015 14:54:41 +0000 (+0100) Subject: mon: services: use op-based reply_command() X-Git-Tag: v9.1.0~535^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9ba818f98d33bff70a9e3cb592d5c931f34f9b1b;p=ceph.git mon: services: use op-based reply_command() Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index fb6c753787ff..35c63b0a2866 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -526,7 +526,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -543,7 +543,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -553,7 +553,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) EntityName entity; if (!entity_name.empty() && !entity.from_str(entity_name)) { ss << "invalid entity_auth " << entity_name; - mon->reply_command(m, -EINVAL, ss.str(), get_last_committed()); + mon->reply_command(op, -EINVAL, ss.str(), get_last_committed()); return true; } @@ -639,7 +639,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) rdata.append(ds); string rs; getline(ss, rs, '\0'); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -675,7 +675,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -692,7 +692,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -715,7 +715,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) if (bl.length() == 0) { ss << "auth import: no data supplied"; getline(ss, rs); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } bufferlist::iterator iter = bl.begin(); @@ -1000,7 +1000,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) done: rdata.append(ds); getline(ss, rs, '\0'); - mon->reply_command(m, err, rs, rdata, get_last_committed()); + mon->reply_command(op, err, rs, rdata, get_last_committed()); return false; } diff --git a/src/mon/ConfigKeyService.cc b/src/mon/ConfigKeyService.cc index 5a26c5730f92..dc43ce5c7be0 100644 --- a/src/mon/ConfigKeyService.cc +++ b/src/mon/ConfigKeyService.cc @@ -194,7 +194,7 @@ bool ConfigKeyService::service_dispatch(MonOpRequestRef op) out: if (!cmd->get_source().is_mon()) { string rs = ss.str(); - mon->reply_command(cmd, ret, rs, rdata, 0); + mon->reply_command(op, ret, rs, rdata, 0); } return (ret == 0); diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 53be8f6a55dd..c571c69f818f 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -378,7 +378,6 @@ bool LogMonitor::should_propose(double& delay) bool LogMonitor::preprocess_command(MonOpRequestRef op) { op->mark_logmon_event("preprocess_command"); - MMonCommand *m = static_cast(op->get_req()); int r = -1; bufferlist rdata; stringstream ss; @@ -386,7 +385,7 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op) if (r != -1) { string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -405,7 +404,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -414,7 +413,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -435,7 +434,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) } getline(ss, rs); - mon->reply_command(m, err, rs, get_last_committed()); + mon->reply_command(op, err, rs, get_last_committed()); return false; } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 87d463bbead8..91d6cfbaad9a 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -741,7 +741,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -753,7 +753,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -943,7 +943,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) rdata.append(ds); string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -1060,7 +1060,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -1070,7 +1070,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) /* Refuse access if message not associated with a valid session */ MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1114,7 +1114,7 @@ out: return true; } else { // reply immediately - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return false; } } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 42d29e053598..008250efcd7c 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2554,20 +2554,20 @@ void Monitor::handle_command(MonOpRequestRef op) MMonCommand *m = static_cast(op->get_req()); if (m->fsid != monmap->fsid) { dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl; - reply_command(m, -EPERM, "wrong fsid", 0); + reply_command(op, -EPERM, "wrong fsid", 0); return; } MonSession *session = m->get_session(); if (!session) { string rs = "Access denied"; - reply_command(m, -EACCES, rs, 0); + reply_command(op, -EACCES, rs, 0); return; } if (m->cmd.empty()) { string rs = "No command supplied"; - reply_command(m, -EINVAL, rs, 0); + reply_command(op, -EINVAL, rs, 0); return; } @@ -2585,7 +2585,7 @@ void Monitor::handle_command(MonOpRequestRef op) r = -EINVAL; rs = ss.str(); if (!m->get_source().is_mon()) // don't reply to mon->mon commands - reply_command(m, r, rs, 0); + reply_command(op, r, rs, 0); return; } @@ -2596,7 +2596,7 @@ void Monitor::handle_command(MonOpRequestRef op) format_command_descriptions(leader_supported_mon_commands, leader_supported_mon_commands_size, f, &rdata); delete f; - reply_command(m, 0, "", rdata, 0); + reply_command(op, 0, "", rdata, 0); return; } @@ -2620,7 +2620,7 @@ void Monitor::handle_command(MonOpRequestRef op) const_cast(leader_supported_mon_commands), leader_supported_mon_commands_size); if (!leader_cmd) { - reply_command(m, -EINVAL, "command not known", 0); + reply_command(op, -EINVAL, "command not known", 0); return; } // validate command is in our map & matches, or forward if it is allowed @@ -2629,7 +2629,7 @@ void Monitor::handle_command(MonOpRequestRef op) if (!is_leader()) { if (!mon_cmd) { if (leader_cmd->is_noforward()) { - reply_command(m, -EINVAL, + reply_command(op, -EINVAL, "command not locally supported and not allowed to forward", 0); return; @@ -2640,7 +2640,7 @@ void Monitor::handle_command(MonOpRequestRef op) return; } else if (!mon_cmd->is_compat(leader_cmd)) { if (mon_cmd->is_noforward()) { - reply_command(m, -EINVAL, + reply_command(op, -EINVAL, "command not compatible with leader and not allowed to forward", 0); return; @@ -2655,7 +2655,7 @@ void Monitor::handle_command(MonOpRequestRef op) if (mon_cmd->is_obsolete() || (cct->_conf->mon_debug_deprecated_as_obsolete && mon_cmd->is_deprecated())) { - reply_command(m, -ENOTSUP, + reply_command(op, -ENOTSUP, "command is obsolete; please check usage and/or man page", 0); return; @@ -2663,7 +2663,7 @@ void Monitor::handle_command(MonOpRequestRef op) if (session->proxy_con && mon_cmd->is_noforward()) { dout(10) << "Got forward for noforward command " << m << dendl; - reply_command(m, -EINVAL, "forward for noforward command", rdata, 0); + reply_command(op, -EINVAL, "forward for noforward command", rdata, 0); return; } @@ -2687,7 +2687,7 @@ void Monitor::handle_command(MonOpRequestRef op) << "from='" << session->inst << "' " << "entity='" << session->entity_name << "' " << "cmd=" << m->cmd << ": access denied"; - reply_command(m, -EACCES, "access denied", 0); + reply_command(op, -EACCES, "access denied", 0); return; } @@ -2746,7 +2746,7 @@ void Monitor::handle_command(MonOpRequestRef op) ds << monmap->fsid; rdata.append(ds); } - reply_command(m, 0, "", rdata, 0); + reply_command(op, 0, "", rdata, 0); return; } @@ -2754,11 +2754,11 @@ void Monitor::handle_command(MonOpRequestRef op) wait_for_paxos_write(); if (is_leader()) { int r = scrub_start(); - reply_command(m, r, "", rdata, 0); + reply_command(op, r, "", rdata, 0); } else if (is_peon()) { forward_request_leader(m); } else { - reply_command(m, -EAGAIN, "no quorum", rdata, 0); + reply_command(op, -EAGAIN, "no quorum", rdata, 0); } return; } @@ -3003,7 +3003,7 @@ void Monitor::handle_command(MonOpRequestRef op) out: if (!m->get_source().is_mon()) // don't reply to mon->mon commands - reply_command(m, r, rs, rdata, 0); + reply_command(op, r, rs, rdata, 0); } void Monitor::reply_command(MMonCommand *m, int rc, const string &rs, version_t version) diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 38638b8c3bef..e5a5d6cde948 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -847,7 +847,7 @@ public: ss << "cmd='" << m->cmd << "': finished"; mon->audit_clog->info() << ss.str(); - mon->reply_command(m, rc, rs, rdata, version); + mon->reply_command(op, rc, rs, rdata, version); } else if (r == -ECANCELED) return; diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index a30faee32c81..f60d399c8efd 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -164,7 +164,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -173,7 +173,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -250,7 +250,7 @@ reply: string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -284,7 +284,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -293,7 +293,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -377,7 +377,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) ss << "removed mon." << name << " at " << addr << ", there are now " << pending_map.size() << " monitors" ; getline(ss, rs); // send reply immediately in case we get removed - mon->reply_command(m, 0, rs, get_last_committed()); + mon->reply_command(op, 0, rs, get_last_committed()); return true; } else @@ -385,7 +385,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) out: getline(ss, rs); - mon->reply_command(m, err, rs, get_last_committed()); + mon->reply_command(op, err, rs, get_last_committed()); return false; } diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 60ea768a80c2..8d178953eda5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2874,13 +2874,13 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -3801,7 +3801,7 @@ stats_out: reply: string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -4859,13 +4859,13 @@ bool OSDMonitor::prepare_command(MonOpRequestRef op) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -7068,7 +7068,7 @@ done: getline(ss, rs); if (err < 0 && rs.length() == 0) rs = cpp_strerror(err); - mon->reply_command(m, err, rs, rdata, get_last_committed()); + mon->reply_command(op, err, rs, rdata, get_last_committed()); return ret; update: diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index f8185998bab5..2be053745764 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -1475,7 +1475,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -1484,7 +1484,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1516,7 +1516,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op) r = -ENOENT; ss << "pool " << poolstr << " does not exist"; string rs = ss.str(); - mon->reply_command(m, r, rs, get_last_committed()); + mon->reply_command(op, r, rs, get_last_committed()); return true; } cmd_putval(g_ceph_context, cmdmap, "pool", pool); @@ -1786,7 +1786,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op) string rs; getline(ss, rs); rdata.append(ds); - mon->reply_command(m, r, rs, rdata, get_last_committed()); + mon->reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -1804,7 +1804,7 @@ bool PGMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_last_committed()); + mon->reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -1813,7 +1813,7 @@ bool PGMonitor::prepare_command(MonOpRequestRef op) MonSession *session = m->get_session(); if (!session) { - mon->reply_command(m, -EACCES, "access denied", get_last_committed()); + mon->reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -1867,7 +1867,7 @@ bool PGMonitor::prepare_command(MonOpRequestRef op) getline(ss, rs); if (r < 0 && rs.length() == 0) rs = cpp_strerror(r); - mon->reply_command(m, r, rs, get_last_committed()); + mon->reply_command(op, r, rs, get_last_committed()); return false; update: