From 283b3a6849215137daf540b9ba5d8a528b998dbe Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 12 Apr 2018 22:54:33 -0700 Subject: [PATCH] mds: evict all clients if last mds shutting down 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 --- src/mds/MDSRank.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index dd01e194ae9..8d8faf199d0 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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 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(); -- 2.39.5