]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: mark con for closed session disposable
authorSage Weil <sage@inktank.com>
Wed, 13 Mar 2013 02:44:20 +0000 (19:44 -0700)
committerSage Weil <sage@inktank.com>
Wed, 13 Mar 2013 23:38:28 +0000 (16:38 -0700)
If there is a fault while delivering the message, close the con.  This will
clean up the Session state from memory.  If the client doesn't get the
CLOSED message, they will reconnect (from their perspective, it is still
a lossless connection) and get a remote_reset event telling them that the
session is gone.  The client code already handles this case properly.

Note that way back in 4ac45200f10e0409121948cea5226ca9e23bb5fb we removed
this because the client would reuse the same connection when it reopened
the session.  Now the client never does that; it will mark_down the con
as soon as it is closed and open a new one for a new session... which means
the MDS will get a remote_reset and close out the old session.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mds/MDS.cc
src/mds/Server.cc

index bf56778b0f5f5daf74bc8c8918845b1d06c8f933..6c5a3693c324fb6b11ef541b581136001d92d44d 100644 (file)
@@ -2050,6 +2050,17 @@ void MDS::ms_handle_remote_reset(Connection *con)
   case CEPH_ENTITY_TYPE_OSD:
     objecter->ms_handle_remote_reset(con);
     break;
+
+  case CEPH_ENTITY_TYPE_CLIENT:
+    Session *session = static_cast<Session *>(con->get_priv());
+    if (session) {
+      if (session->is_closed()) {
+       messenger->mark_down(con);
+       sessionmap.remove_session(session);
+      }
+      session->put();
+    }
+    break;
   }
 }
 
index d3acd15a0fd6df52999491507c1fa1d535bbef80..ad3912bb0779d56baf2b61721e14181b262da523 100644 (file)
@@ -299,6 +299,14 @@ void Server::_session_logged(Session *session, uint64_t state_seq, bool open, ve
     }
     
     if (session->is_closing()) {
+      // mark con disposable.  if there is a fault, we will get a
+      // reset and clean it up.  if the client hasn't received the
+      // CLOSE message yet, they will reconnect and get an
+      // ms_handle_remote_reset() and realize they had in fact closed.
+      // do this *before* sending the message to avoid a possible
+      // race.
+      mds->messenger->mark_disposable(session->connection);
+
       // reset session
       mds->send_message_client(new MClientSession(CEPH_SESSION_CLOSE), session);
       mds->sessionmap.set_state(session, Session::STATE_CLOSED);