From 841fc496cf809e20c7ae552b1d012e363b5af626 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 25 Sep 2018 14:18:00 -0400 Subject: [PATCH] osdc/Objecter: possible race condition with connection reset If the connection quickly fails before the private session reference can be associated with the connection, the connection will remain closed and any OSD ops against the session will remain stuck. Fixes: http://tracker.ceph.com/issues/36183 Signed-off-by: Jason Dillaman (cherry picked from commit 74ca33cb49d2c258324447b1ca366ed4e604202a) --- src/osdc/Objecter.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 98bd84eb6cf6b..3ad0bc516e9f1 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -1834,6 +1834,7 @@ void Objecter::get_session(Objecter::OSDSession *s) void Objecter::_reopen_session(OSDSession *s) { + // rwlock is locked unique // s->lock is locked entity_inst_t inst = osdmap->get_inst(s->osd); @@ -4417,12 +4418,13 @@ bool Objecter::ms_handle_reset(Connection *con) if (!initialized) return false; if (con->get_peer_type() == CEPH_ENTITY_TYPE_OSD) { + unique_lock wl(rwlock); + auto priv = con->get_priv(); auto session = static_cast(priv.get()); if (session) { ldout(cct, 1) << "ms_handle_reset " << con << " session " << session << " osd." << session->osd << dendl; - unique_lock wl(rwlock); if (!initialized) { wl.unlock(); return false; -- 2.39.5