]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: reset session->osdmap if session is not waiting for a map anymore
authorKefu Chai <kchai@redhat.com>
Thu, 12 May 2016 12:28:11 +0000 (20:28 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 17 May 2016 05:23:43 +0000 (13:23 +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>
src/osd/OSD.cc
src/osd/OSD.h

index 973f3eb2cd9013e8b67ca456c3ef9bb16f57c56e..9a22a79ad0a69b86d54e5af39bea739e97108fac 100644 (file)
@@ -5886,6 +5886,7 @@ void OSD::dispatch_session_waiting(Session *session, OSDMapRef osdmap)
   } else {
     register_session_waiting_on_map(session);
   }
+  session->maybe_reset_osdmap();
 }
 
 
@@ -5964,6 +5965,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 fd40d3b1867b2a3fbe8f3f9d713316b27cbb36aa..c97f7ec55a4d0e03ef2a913a01221b0377e4a4b1 100644 (file)
@@ -1342,8 +1342,11 @@ public:
       session_dispatch_lock("Session::session_dispatch_lock"), 
       last_sent_epoch(0), 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);
@@ -1442,6 +1445,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);