]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: reset session->osdmap if session is not waiting for a map anymore 9090/head
authorKefu Chai <kchai@redhat.com>
Thu, 12 May 2016 12:28:11 +0000 (20:28 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 15 Jul 2016 10:03:09 +0000 (18:03 +0800)
we should release the osdmap reference once we are done with it,
otherwise we might need to wait very long to update that reference with
a newer osdmap ref. this appears to be an OSDMap leak: it is held by an
quiet OSD::Session forever.

the osdmap is not reset in OSD::session_notify_pg_create(), because its
only caller is wake_pg_waiters(), which will call
dispatch_session_waiting() later. and dispatch_session_waiting() will
check the session->osdmap, and will also reset the osdmap if
session->waiting_for_pg.empty().

Fixes: http://tracker.ceph.com/issues/13990
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 82b0af7cedc3071cd83ee53479f834c23c62b7d0)

src/osd/OSD.cc
src/osd/OSD.h

index 33c42da3de95e42670affc008164800dca8cdf5c..04334aaeff495c09ee4dca1d2b0fa54028934a88 100644 (file)
@@ -5444,6 +5444,7 @@ void OSD::dispatch_session_waiting(Session *session, OSDMapRef osdmap)
   } else {
     register_session_waiting_on_map(session);
   }
+  session->maybe_reset_osdmap();
 }
 
 
@@ -5522,6 +5523,7 @@ void OSD::session_notify_pg_cleared(
   assert(session->session_dispatch_lock.is_locked());
   update_waiting_for_pg(session, osdmap);
   session->waiting_for_pg.erase(pgid);
+  session->maybe_reset_osdmap();
   clear_session_waiting_on_pg(session, pgid);
 }
 
index 4e564d3ee1773b264c1760de8f5d5a07a39cd4a0..bfc6ff933e7b277d13b0b42c7b0ef2f0fedc90fd 100644 (file)
@@ -1161,8 +1161,11 @@ public:
       sent_epoch_lock("Session::sent_epoch_lock"), last_sent_epoch(0),
       received_map_lock("Session::received_map_lock"), received_map_epoch(0)
     {}
-
-
+    void maybe_reset_osdmap() {
+      if (waiting_for_pg.empty()) {
+       osdmap.reset();
+      }
+    }
   };
   void update_waiting_for_pg(Session *session, OSDMapRef osdmap);
   void session_notify_pg_create(Session *session, OSDMapRef osdmap, spg_t pgid);
@@ -1266,6 +1269,7 @@ public:
      */
     session->waiting_on_map.clear();
     session->waiting_for_pg.clear();
+    session->osdmap.reset();
   }
   void register_session_waiting_on_pg(Session *session, spg_t pgid) {
     Mutex::Locker l(session_waiting_lock);