]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: evict all clients if last mds shutting down
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 13 Apr 2018 05:54:33 +0000 (22:54 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 17 Apr 2018 18:01:24 +0000 (11:01 -0700)
This allows all ranks to stop. If the administrator shuts down the cluster then
we should immediately shut down all client's I/O.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSRank.cc

index dd01e194ae959adf3438a60d996bb97df9d533af..8d8faf199d0eb2fc18e8bead65d9ac30694bbed3 100644 (file)
@@ -1581,9 +1581,27 @@ void MDSRank::stopping_start()
   dout(2) << "stopping_start" << dendl;
 
   if (mdsmap->get_num_in_mds() == 1 && !sessionmap.empty()) {
-    // we're the only mds up!
-    dout(0) << "we are the last MDS, and have mounted clients: we cannot flush our journal.  suicide!" << dendl;
-    suicide();
+    std::vector<Session*> victims;
+    const auto sessions = sessionmap.get_sessions();
+    for (const auto p : sessions)  {
+      if (!p.first.is_client()) {
+        continue;
+      }
+
+      Session *s = p.second;
+      victims.push_back(s);
+    }
+
+    dout(20) << __func__ << " matched " << victims.size() << " sessions" << dendl;
+    assert(!victims.empty());
+
+    C_GatherBuilder gather(g_ceph_context, new C_MDSInternalNoop);
+    for (const auto &s : victims) {
+      std::stringstream ss;
+      evict_client(s->get_client().v, false,
+                   g_conf->mds_session_blacklist_on_evict, ss, gather.new_sub());
+    }
+    gather.activate();
   }
 
   mdcache->shutdown_start();