]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: services: use op-based reply_command()
authorJoao Eduardo Luis <joao@suse.de>
Wed, 17 Jun 2015 14:54:41 +0000 (15:54 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 16 Jul 2015 17:31:22 +0000 (18:31 +0100)
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/AuthMonitor.cc
src/mon/ConfigKeyService.cc
src/mon/LogMonitor.cc
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc

index fb6c753787ff1c21e62374685d9af0dbed0bbc3c..35c63b0a28667b70fef2a10f072cabaa97a6946b 100644 (file)
@@ -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;
 }
 
index 5a26c5730f92c52afef13150909d0449878f1bc7..dc43ce5c7be0d2ec6e0838bb521072ccb73e544a 100644 (file)
@@ -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);
index 53be8f6a55dde495f3fdc209649ef8957488c7bb..c571c69f818fb8481dccb5fd007e89c77f5b812e 100644 (file)
@@ -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<MMonCommand*>(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;
 }
 
index 87d463bbead8afae37e9bdebbe8047a8796a8af0..91d6cfbaad9afe22394bf2695002821c4ff823f3 100644 (file)
@@ -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<string, cmd_vartype> 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;
   }
 }
index 42d29e05359845e26c10c8dfda3090e9b8686575..008250efcd7cab0b08f06d2ef46f717ad3af5352 100644 (file)
@@ -2554,20 +2554,20 @@ void Monitor::handle_command(MonOpRequestRef op)
   MMonCommand *m = static_cast<MMonCommand*>(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<MonCommand*>(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)
index 38638b8c3bef4aef66a9f274727b4ff1266120a0..e5a5d6cde948052dd31f9ebf714cad1603a28a68 100644 (file)
@@ -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;
index a30faee32c81db9702a489ad1d779802d56f36d1..f60d399c8efdf9ece5c0a8b82da76be9bd4aefe4 100644 (file)
@@ -164,7 +164,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op)
   map<string, cmd_vartype> 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<string, cmd_vartype> 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;
 }
 
index 60ea768a80c2a50fbfe19a673e9eb74bd2cbc003..8d178953eda5fab2af20539a52ab5e7346c5ad0e 100644 (file)
@@ -2874,13 +2874,13 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
   map<string, cmd_vartype> 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<string, cmd_vartype> 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:
index f8185998bab51decf58b8cb837125f6586e950db..2be053745764e9ba5abd2659a4d73e6cc69f555b 100644 (file)
@@ -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: