]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: close client sessions after stopping mds exports all subtrees
authorYan, Zheng <zyan@redhat.com>
Mon, 20 Mar 2017 08:57:28 +0000 (16:57 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 30 Mar 2017 01:46:05 +0000 (09:46 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h

index 03b40c3701d5dead89920fdc13c4163ca44d6c1a..09f1113e61f68b8d730036fa34b0247581228827 100644 (file)
@@ -7446,14 +7446,6 @@ bool MDCache::shutdown_pass()
     return true;
   }
 
-  // close out any sessions (and open files!) before we try to trim the log, etc.
-  if (!mds->server->terminating_sessions &&
-      mds->sessionmap.have_unclosed_sessions()) {
-    mds->server->terminate_sessions();
-    return false;
-  }
-
-
   // empty stray dir
   if (!shutdown_export_strays()) {
     dout(7) << "waiting for strays to migrate" << dendl;
@@ -7475,6 +7467,7 @@ bool MDCache::shutdown_pass()
   dout(5) << "lru size now " << lru.lru_get_size() << dendl;
 
   // SUBTREES
+  int num_auth_subtree = 0;
   if (!subtrees.empty() &&
       mds->get_nodeid() != 0 && 
       !migrator->is_exporting() //&&
@@ -7488,11 +7481,14 @@ bool MDCache::shutdown_pass()
       CDir *dir = it->first;
       if (dir->get_inode()->is_mdsdir())
        continue;
-      if (dir->is_frozen() || dir->is_freezing())
-       continue;
-      if (!dir->is_full_dir_auth())
-       continue;
-      ls.push_back(dir);
+      if (dir->is_auth()) {
+       num_auth_subtree++;
+       if (dir->is_frozen() ||
+           dir->is_freezing() ||
+           dir->is_ambiguous_dir_auth())
+         continue;
+       ls.push_back(dir);
+      }
     }
     int max = 5; // throttle shutdown exports.. hack!
     for (list<CDir*>::iterator p = ls.begin(); p != ls.end(); ++p) {
@@ -7507,8 +7503,16 @@ bool MDCache::shutdown_pass()
     }
   }
 
-  if (!shutdown_export_caps()) {
-    dout(7) << "waiting for residual caps to export" << dendl;
+  if (num_auth_subtree > 0) {
+    dout(7) << "still have " << num_auth_subtree << " auth subtrees" << dendl;
+    show_subtrees();
+    return false;
+  }
+
+  // close out any sessions (and open files!) before we try to trim the log, etc.
+  if (mds->sessionmap.have_unclosed_sessions()) {
+    if (!mds->server->terminating_sessions)
+      mds->server->terminate_sessions();
     return false;
   }
 
@@ -7654,54 +7658,6 @@ bool MDCache::shutdown_export_strays()
   return done;
 }
 
-bool MDCache::shutdown_export_caps()
-{
-  // export caps?
-  //  note: this runs more often than it should.
-  static bool exported_caps = false;
-  static set<CDir*> exported_caps_in;
-  if (!exported_caps) {
-    dout(7) << "searching for caps to export" << dendl;
-    exported_caps = true;
-
-    list<CDir*> dirq;
-    for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
-        p != subtrees.end();
-        ++p) {
-      if (exported_caps_in.count(p->first)) continue;
-      if (p->first->is_auth() ||
-         p->first->is_ambiguous_auth())
-       exported_caps = false; // we'll have to try again
-      else {
-       dirq.push_back(p->first);
-       exported_caps_in.insert(p->first);
-      }
-    }
-    while (!dirq.empty()) {
-      CDir *dir = dirq.front();
-      dirq.pop_front();
-      for (CDir::map_t::iterator p = dir->items.begin();
-          p != dir->items.end();
-          ++p) {
-       CDentry *dn = p->second;
-       CDentry::linkage_t *dnl = dn->get_linkage();
-       if (!dnl->is_primary()) continue;
-       CInode *in = dnl->get_inode();
-       if (in->is_dir())
-         in->get_nested_dirfrags(dirq);
-       if (in->is_any_caps() && !in->state_test(CInode::STATE_EXPORTINGCAPS))
-         migrator->export_caps(in);
-      }
-    }
-  }
-
-  return true;
-}
-
-
-
-
-
 // ========= messaging ==============
 
 /* This function DOES put the passed message before returning */
index 27f12bbb08c8cac6d07304072ea2509745e7a6db..76e779794a7455d327199ca31835b21734a86e64 100644 (file)
@@ -709,7 +709,6 @@ public:
   void shutdown_check();
   bool shutdown_pass();
   bool shutdown_export_strays();
-  bool shutdown_export_caps();
   bool shutdown();                    // clear cache (ie at shutodwn)
 
   bool did_shutdown_log_cap;