From: Kefu Chai Date: Thu, 12 May 2016 12:28:11 +0000 (+0800) Subject: osd: reset session->osdmap if session is not waiting for a map anymore X-Git-Tag: v0.94.8~37^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F9090%2Fhead;p=ceph.git osd: reset session->osdmap if session is not waiting for a map anymore 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 (cherry picked from commit 82b0af7cedc3071cd83ee53479f834c23c62b7d0) --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 33c42da3de95..04334aaeff49 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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); } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 4e564d3ee177..bfc6ff933e7b 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -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);