]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: avoid require_mon_peer stray put()
authorSage Weil <sage@redhat.com>
Thu, 16 Feb 2017 21:58:29 +0000 (16:58 -0500)
committerSage Weil <sage@redhat.com>
Mon, 20 Feb 2017 19:12:23 +0000 (14:12 -0500)
For the handle_pg_create caller we cannot put the ref; do it in the callers
instead.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 08b727f5d25bd2653b53301cd6b350020b014e13..6953861138624bc4c5f958b78d965e1b7f5f9232 100644 (file)
@@ -5373,6 +5373,7 @@ void OSD::handle_pg_stats_ack(MPGStatsAck *ack)
   dout(10) << "handle_pg_stats_ack " << dendl;
 
   if (!require_mon_peer(ack)) {
+    ack->put();
     return;
   }
 
@@ -5456,8 +5457,10 @@ void OSD::flush_pg_stats()
 
 void OSD::handle_command(MMonCommand *m)
 {
-  if (!require_mon_peer(m))
+  if (!require_mon_peer(m)) {
+    m->put();
     return;
+  }
 
   Command *c = new Command(m->cmd, m->get_tid(), m->get_data(), NULL);
   command_wq.queue(c);
@@ -6575,8 +6578,10 @@ void OSD::handle_pg_scrub(MOSDScrub *m, PG *pg)
 void OSD::handle_scrub(MOSDScrub *m)
 {
   dout(10) << "handle_scrub " << *m << dendl;
-  if (!require_mon_peer(m))
+  if (!require_mon_peer(m)) {
+    m->put();
     return;
+  }
   if (m->fsid != monc->get_fsid()) {
     dout(0) << "handle_scrub fsid " << m->fsid << " != " << monc->get_fsid() << dendl;
     m->put();
@@ -7616,13 +7621,12 @@ void OSD::activate_map()
   take_waiters(waiting_for_osdmap);
 }
 
-bool OSD::require_mon_peer(Message *m)
+bool OSD::require_mon_peer(const Message *m)
 {
   if (!m->get_connection()->peer_is_mon()) {
     dout(0) << "require_mon_peer received from non-mon "
            << m->get_connection()->get_peer_addr()
            << " " << *m << dendl;
-    m->put();
     return false;
   }
   return true;
@@ -7789,16 +7793,9 @@ void OSD::handle_pg_create(OpRequestRef op)
 
   dout(10) << "handle_pg_create " << *m << dendl;
 
-  /* we have to hack around require_mon_peer's interface limits, so
-   * grab an extra reference before going in. If the peer isn't
-   * a Monitor, the reference is put for us (and then cleared
-   * up automatically by our OpTracker infrastructure). Otherwise,
-   * we put the extra ref ourself.
-   */
-  if (!require_mon_peer(op->get_req()->get())) {
+  if (!require_mon_peer(op->get_req())) {
     return;
   }
-  op->get_req()->put();
 
   if (!require_same_or_newer_map(op, m->epoch, false))
     return;
index 3beb717e419f9a5be3b4291e2b56f48c8047eba1..4b6755da95600063e1065eb0e183b3177a4ca665 100644 (file)
@@ -2230,7 +2230,7 @@ protected:
                    vector<pair<pg_notify_t, pg_interval_map_t> > >& info_map,
                OSDMapRef map);
 
-  bool require_mon_peer(Message *m);
+  bool require_mon_peer(const Message *m);
   bool require_osd_peer(Message *m);
   /***
    * Verifies that we were alive in the given epoch, and that