]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: use MonOpRequest get_session() instead of PaxosServiceMessage's
authorSage Weil <sage@redhat.com>
Tue, 9 Oct 2018 22:08:46 +0000 (17:08 -0500)
committerSage Weil <sage@redhat.com>
Sun, 14 Oct 2018 17:01:09 +0000 (12:01 -0500)
The PaxosServiceMessage method relies on the msg -> con -> session linkage,
and the con -> session link is not present for forwarded messages.  Also,
the message path is redundant and unnecessary.

Signed-off-by: Sage Weil <sage@redhat.com>
src/messages/PaxosServiceMessage.h
src/mon/AuthMonitor.cc
src/mon/LogMonitor.cc
src/mon/MDSMonitor.cc
src/mon/MgrMonitor.cc
src/mon/MgrStatMonitor.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 3532e3eb4f6a3f4a19eee7ebca7ad8efabd01936..a947b548ee04451d60c9df88c7184eec31f22cbb 100644 (file)
@@ -50,19 +50,6 @@ public:
     paxos_decode(p);
   }
 
-  /** 
-   * These messages are only used by the monitors and clients,
-   * and the client doesn't care, so we're creating a monitor-specific
-   * function here. Note that this function explicitly exists to bypass
-   * the normal ref-counting, so don't expect the returned pointer to be
-   * very long-lived -- it will still only last as long as the Session would
-   * normally.
-   */
-  MonSession *get_session() {
-    auto priv = get_connection()->get_priv();
-    return static_cast<MonSession*>(priv.get());
-  }
-  
   const char *get_type_name() const override { return "PaxosServiceMessage"; }
 };
 
index 2c28a972b091c4a9931724d6e81a999412b8d88b..9ad3de87fb1a1997488576f3603a2efe9f8aa385 100644 (file)
@@ -703,7 +703,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op)
     return false;
   }
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
     return true;
@@ -1227,7 +1227,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op)
   cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain"));
   boost::scoped_ptr<Formatter> f(Formatter::create(format));
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
     return true;
index 8ca3bab0fc5a78b611692296859cdeccf9c6a305..85a982ba50ea0967cfa29c3d79dad9b22381a3f8 100644 (file)
@@ -304,7 +304,7 @@ bool LogMonitor::preprocess_log(MonOpRequestRef op)
   dout(10) << "preprocess_log " << *m << " from " << m->get_orig_source() << dendl;
   int num_new = 0;
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto done;
   if (!session->is_capable("log", MON_CAP_W)) {
@@ -402,7 +402,7 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op)
     mon->reply_command(op, -EINVAL, rs, get_last_committed());
     return true;
   }
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
@@ -532,7 +532,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op)
   string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
index 1e2351f70a11b40404f61da1d3b609b0f4c48a50..169225c9091e86335fe55a4e64fb4a3f7ce43a3d 100644 (file)
@@ -327,7 +327,7 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op)
   const auto &fsmap = get_fsmap();
 
   // check privileges, ignore if fails
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("mds", MON_CAP_X)) {
@@ -473,7 +473,7 @@ bool MDSMonitor::preprocess_offload_targets(MonOpRequestRef op)
   const auto &fsmap = get_fsmap();
   
   // check privileges, ignore message if fails
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("mds", MON_CAP_X)) {
@@ -904,7 +904,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op)
   cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain"));
   std::unique_ptr<Formatter> f(Formatter::create(format));
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
     return true;
@@ -1215,7 +1215,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op)
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
   /* Refuse access if message not associated with a valid session */
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
     return true;
index 39442c05dc925742a80eb745336157127cabe326..df053ce87e46c451b734fd0cddd2517773983608 100644 (file)
@@ -744,7 +744,7 @@ bool MgrMonitor::preprocess_command(MonOpRequestRef op)
     return true;
   }
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata,
                       get_last_committed());
@@ -887,7 +887,7 @@ bool MgrMonitor::prepare_command(MonOpRequestRef op)
     return true;
   }
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed());
     return true;
index ab87ab42edc72becb6e171de3c6b4dbad99e1103..caf1dcb04a86223e434dea92ecc3993c5bdd4fd8 100644 (file)
@@ -212,7 +212,7 @@ bool MgrStatMonitor::preprocess_getpoolstats(MonOpRequestRef op)
 {
   op->mark_pgmon_event(__func__);
   auto m = static_cast<MGetPoolStats*>(op->get_req());
-  auto session = m->get_session();
+  auto session = op->get_session();
   if (!session)
     return true;
   if (!session->is_capable("pg", MON_CAP_R)) {
@@ -244,7 +244,7 @@ bool MgrStatMonitor::preprocess_statfs(MonOpRequestRef op)
 {
   op->mark_pgmon_event(__func__);
   auto statfs = static_cast<MStatfs*>(op->get_req());
-  auto session = statfs->get_session();
+  auto session = op->get_session();
 
   if (!session)
     return true;
index 667fdf2d4a19a861ccb70f2fafc937e4fb8c2fcc..ff2c8d7539526e6c91a5a5627b5644992eb89049 100644 (file)
@@ -247,7 +247,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op)
   string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
@@ -445,7 +445,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
   string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
@@ -725,7 +725,7 @@ bool MonmapMonitor::preprocess_join(MonOpRequestRef op)
   MMonJoin *join = static_cast<MMonJoin*>(op->get_req());
   dout(10) << __func__ << " " << join->name << " at " << join->addr << dendl;
 
-  MonSession *session = join->get_session();
+  MonSession *session = op->get_session();
   if (!session ||
       !session->is_capable("mon", MON_CAP_W | MON_CAP_X)) {
     dout(10) << " insufficient caps" << dendl;
index baf1dcaf38200256258c2dfb925a5af1a44ae7e3..471855cf68eb3c3afabb6c9b5019ee95b89a71bb 100644 (file)
@@ -2217,8 +2217,8 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op)
   MMonGetOSDMap *m = static_cast<MMonGetOSDMap*>(op->get_req());
 
   uint64_t features = mon->get_quorum_con_features();
-  if (m->get_session() && m->get_session()->con_features)
-    features = m->get_session()->con_features;
+  if (op->get_session() && op->get_session()->con_features)
+    features = op->get_session()->con_features;
 
   dout(10) << __func__ << " " << *m << dendl;
   MOSDMap *reply = new MOSDMap(mon->monmap->fsid, features);
@@ -2249,9 +2249,9 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op)
 
 // failure --
 
-bool OSDMonitor::check_source(PaxosServiceMessage *m, uuid_d fsid) {
+bool OSDMonitor::check_source(MonOpRequestRef op, uuid_d fsid) {
   // check permissions
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     return true;
   if (!session->is_capable("osd", MON_CAP_X)) {
@@ -2276,7 +2276,7 @@ bool OSDMonitor::preprocess_failure(MonOpRequestRef op)
   int badboy = m->get_target_osd();
 
   // check permissions
-  if (check_source(m, m->fsid))
+  if (check_source(op, m->fsid))
     goto didit;
 
   // first, verify the reporting host is valid
@@ -2370,7 +2370,7 @@ bool OSDMonitor::preprocess_mark_me_down(MonOpRequestRef op)
   int from = m->target_osd;
 
   // check permissions
-  if (check_source(m, m->fsid))
+  if (check_source(op, m->fsid))
     goto reply;
 
   // first, verify the reporting host is valid
@@ -2755,7 +2755,7 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op)
   int from = m->get_orig_source_inst().name.num();
 
   // check permissions, ignore if failed (no response expected)
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("osd", MON_CAP_X)) {
@@ -3050,7 +3050,7 @@ bool OSDMonitor::preprocess_full(MonOpRequestRef op)
   unsigned mask = CEPH_OSD_NEARFULL | CEPH_OSD_BACKFILLFULL | CEPH_OSD_FULL;
 
   // check permissions, ignore if failed
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("osd", MON_CAP_X)) {
@@ -3139,7 +3139,7 @@ bool OSDMonitor::preprocess_alive(MonOpRequestRef op)
   int from = m->get_orig_source().num();
 
   // check permissions, ignore if failed
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("osd", MON_CAP_X)) {
@@ -3204,7 +3204,7 @@ bool OSDMonitor::preprocess_pg_created(MonOpRequestRef op)
   op->mark_osdmon_event(__func__);
   auto m = static_cast<MOSDPGCreated*>(op->get_req());
   dout(10) << __func__ << " " << *m << dendl;
-  auto session = m->get_session();
+  auto session = op->get_session();
   mon->no_reply(op);
   if (!session) {
     dout(10) << __func__ << ": no monitor session!" << dendl;
@@ -3242,7 +3242,7 @@ bool OSDMonitor::preprocess_pg_ready_to_merge(MonOpRequestRef op)
   auto m = static_cast<MOSDPGReadyToMerge*>(op->get_req());
   dout(10) << __func__ << " " << *m << dendl;
   const pg_pool_t *pi;
-  auto session = m->get_session();
+  auto session = op->get_session();
   if (!session) {
     dout(10) << __func__ << ": no monitor session!" << dendl;
     goto ignore;
@@ -3343,7 +3343,7 @@ bool OSDMonitor::preprocess_pgtemp(MonOpRequestRef op)
   size_t ignore_cnt = 0;
 
   // check caps
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->is_capable("osd", MON_CAP_X)) {
@@ -3486,7 +3486,7 @@ bool OSDMonitor::preprocess_remove_snaps(MonOpRequestRef op)
   dout(7) << "preprocess_remove_snaps " << *m << dendl;
 
   // check privilege, ignore if failed
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     goto ignore;
   if (!session->caps.is_capable(
@@ -3565,9 +3565,8 @@ bool OSDMonitor::prepare_remove_snaps(MonOpRequestRef op)
 bool OSDMonitor::preprocess_beacon(MonOpRequestRef op)
 {
   op->mark_osdmon_event(__func__);
-  auto beacon = static_cast<MOSDBeacon*>(op->get_req());
   // check caps
-  auto session = beacon->get_session();
+  auto session = op->get_session();
   mon->no_reply(op);
   if (!session) {
     dout(10) << __func__ << " no monitor session!" << dendl;
@@ -4530,8 +4529,9 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
     return true;
   }
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
+    derr << __func__ << " no session" << dendl;
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
   }
@@ -6087,7 +6087,7 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op)
   op->mark_osdmon_event(__func__);
   MPoolOp *m = static_cast<MPoolOp*>(op->get_req());
   dout(10) << "prepare_new_pool from " << m->get_connection() << dendl;
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session)
     return -EPERM;
   string erasure_code_profile;
@@ -8054,8 +8054,9 @@ bool OSDMonitor::prepare_command(MonOpRequestRef op)
     return true;
   }
 
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
+    derr << __func__ << " no session" << dendl;
     mon->reply_command(op, -EACCES, "access denied", get_last_committed());
     return true;
   }
@@ -12111,7 +12112,7 @@ bool OSDMonitor::enforce_pool_op_caps(MonOpRequestRef op)
   op->mark_osdmon_event(__func__);
 
   MPoolOp *m = static_cast<MPoolOp*>(op->get_req());
-  MonSession *session = m->get_session();
+  MonSession *session = op->get_session();
   if (!session) {
     _pool_op_reply(op, -EPERM, osdmap.get_epoch());
     return true;
index 8c6ecb864da53573d52c2405747c85c3013e1178..cb7ef1892ef1224e15a8bb3e5c93969704765434 100644 (file)
@@ -358,7 +358,7 @@ public:
 private:
   void print_utilization(ostream &out, Formatter *f, bool tree) const;
 
-  bool check_source(PaxosServiceMessage *m, uuid_d fsid);
+  bool check_source(MonOpRequestRef op, uuid_d fsid);
  
   bool preprocess_get_osdmap(MonOpRequestRef op);