From 87850e96ea6fa45a8368bacabee50f9e95b40ae9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 May 2016 11:26:31 +0800 Subject: [PATCH 1/4] osd/OpRequest: reset connection upon unregister this helps to free the resources referenced by the connection, among other things, in the case of MOSDOp, the OSD::Session and OSDMap. this helps to free the resource earlier and trim the osdmaps in time. Fixes: http://tracker.ceph.com/issues/13990 Signed-off-by: Kefu Chai --- src/osd/OpRequest.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 8805d1a62f0e5..9bad447b69fba 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -82,6 +82,7 @@ void OpRequest::_unregistered() { request->clear_data(); request->clear_payload(); request->release_message_throttle(); + request->set_connection(nullptr); } bool OpRequest::check_rmw(int flag) { From 046c38198a70904fad0c9a5af6d03299f25877a3 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 May 2016 11:45:55 +0800 Subject: [PATCH 2/4] Message: make get_orig_*() alias of get_*() not necessary to construct a entity_inst_t and then throw it away just for extracting the entity_inst_t::name or entity_inst_t::addr. Fixes: http://tracker.ceph.com/issues/13990 Signed-off-by: Kefu Chai --- src/msg/Message.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/msg/Message.h b/src/msg/Message.h index 25b03722bcfd1..d9cd9a23bea02 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -446,10 +446,10 @@ class Message : public RefCountedObject { return get_source_inst(); } entity_name_t get_orig_source() const { - return get_orig_source_inst().name; + return get_source(); } entity_addr_t get_orig_source_addr() const { - return get_orig_source_inst().addr; + return get_source_addr(); } // virtual bits From 82b0af7cedc3071cd83ee53479f834c23c62b7d0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 12 May 2016 20:28:11 +0800 Subject: [PATCH 3/4] 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 --- src/osd/OSD.cc | 2 ++ src/osd/OSD.h | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 973f3eb2cd901..9a22a79ad0a69 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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); } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index fd40d3b1867b2..c97f7ec55a4d0 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1342,8 +1342,11 @@ class OSD : public Dispatcher, 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 @@ class OSD : public Dispatcher, */ 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); From 529260ffc1f664fba142d01288bad574950580e0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 17 May 2016 13:15:10 +0800 Subject: [PATCH 4/4] osd: mark some class members as private Signed-off-by: Kefu Chai --- src/osd/OSD.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osd/OSD.h b/src/osd/OSD.h index c97f7ec55a4d0..ffc98b6b0c1ad 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1348,6 +1348,8 @@ class OSD : public Dispatcher, } } }; + +private: void update_waiting_for_pg(Session *session, OSDMapRef osdmap); void session_notify_pg_create(Session *session, OSDMapRef osdmap, spg_t pgid); void session_notify_pg_cleared(Session *session, OSDMapRef osdmap, spg_t pgid);