]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: close mds sessions in shutdown()
authorJohn Spray <john.spray@redhat.com>
Thu, 15 Oct 2015 00:31:16 +0000 (01:31 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 24 Nov 2015 15:12:12 +0000 (15:12 +0000)
Usually this happens in unmount(), but when we
have instantiated Client without mounting (to
send MDS commands), we need to handle closing
any open sessions in shutdown as well.

This is the correct replacement for the mark_down()
call that was removed from handle_command_reply
in the last commit.

Signed-off-by: John Spray <john.spray@redhat.com>
src/client/Client.cc
src/client/Client.h

index aab30522e8905634d66a1ea915c9658ec2b9d60d..3ccffa6ba766550aa16f45136ce6b8cb0ada3f30 100644 (file)
@@ -554,6 +554,12 @@ void Client::shutdown()
 {
   ldout(cct, 1) << "shutdown" << dendl;
 
+  // If we were not mounted, but were being used for sending
+  // MDS commands, we may have sessions that need closing.
+  client_lock.Lock();
+  close_sessions();
+  client_lock.Unlock();
+
   cct->_conf->remove_observer(this);
 
   AdminSocket* admin_socket = cct->get_admin_socket();
@@ -5100,6 +5106,24 @@ int Client::mount(const std::string &mount_root, bool require_mds)
 
 // UNMOUNT
 
+void Client::close_sessions()
+{
+  while (!mds_sessions.empty()) {
+    // send session closes!
+    for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
+       p != mds_sessions.end();
+       ++p) {
+      if (p->second->state != MetaSession::STATE_CLOSING) {
+       _close_mds_session(p->second);
+      }
+    }
+
+    // wait for sessions to close
+    ldout(cct, 2) << "waiting for " << mds_sessions.size() << " mds sessions to close" << dendl;
+    mount_cond.Wait(client_lock);
+  }
+}
+
 void Client::unmount()
 {
   Mutex::Locker lock(client_lock);
@@ -5184,21 +5208,7 @@ void Client::unmount()
     traceout.close();
   }
 
-  
-  while (!mds_sessions.empty()) {
-    // send session closes!
-    for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
-       p != mds_sessions.end();
-       ++p) {
-      if (p->second->state != MetaSession::STATE_CLOSING) {
-       _close_mds_session(p->second);
-      }
-    }
-
-    // wait for sessions to close
-    ldout(cct, 2) << "waiting for " << mds_sessions.size() << " mds sessions to close" << dendl;
-    mount_cond.Wait(client_lock);
-  }
+  close_sessions();
 
   mounted = false;
 
index 0482360538be59f8b021b94c22d1bcdd97df8735..4c3467003fc361538ea4c36b17bedcfb37844231 100644 (file)
@@ -534,6 +534,8 @@ protected:
    */
   void _handle_full_flag(int64_t pool);
 
+  void close_sessions();
+
  public:
   void set_filer_flags(int flags);
   void clear_filer_flags(int flags);