]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: evict clients that do not respond to cap revoke by MDS
authorVenky Shankar <vshankar@redhat.com>
Mon, 6 Aug 2018 03:37:18 +0000 (23:37 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 18 Oct 2018 12:36:13 +0000 (08:36 -0400)
By default, preserve old behaviour. When configured with a non
default value, evict clients that have not responded to cap
revoke by MDS for the configured amount of seconds.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 4cf7815cdcd8efbbb981ef45b3eabee387b4de21)

 Conflicts:
src/common/options.cc
src/mds/MDSDaemon.cc
src/mds/MDSRank.h

src/common/options.cc
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/Server.cc
src/mds/Server.h

index b81ad60a331f122f64297102599090d9e00a06ae..4b54b7835791230487ad547975f52c41c81cbbac 100644 (file)
@@ -6995,6 +6995,10 @@ std::vector<Option> get_mds_options() {
 
     Option("mds_inject_migrator_session_race", Option::TYPE_BOOL, Option::LEVEL_DEV)
      .set_default(false),
+
+    Option("mds_cap_revoke_eviction_timeout", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
+     .set_default(0)
+     .set_description("number of seconds after which clients which have not responded to cap revoke messages by the MDS are evicted."),
   });
 }
 
index e493a82881ab92d9de08354ac847f8e17608610a..27c3d24d8c515a013c40930d8d49b77eceb3ce55 100644 (file)
@@ -389,6 +389,7 @@ const char** MDSDaemon::get_tracked_conf_keys() const
     "mds_inject_migrator_session_race",
     "host",
     "fsid",
+    "mds_cap_revoke_eviction_timeout",
     NULL
   };
   return KEYS;
index 784142cc725125f3224d8767223db32b943a67d8..96eab39209049c36622f42f86f72781957241f65 100644 (file)
@@ -31,7 +31,6 @@
 #include "MDBalancer.h"
 #include "Migrator.h"
 #include "Locker.h"
-#include "Server.h"
 #include "InoTable.h"
 #include "mon/MonClient.h"
 #include "common/HeartbeatMap.h"
@@ -323,6 +322,7 @@ void MDSRankDispatcher::tick()
   // ...
   if (is_clientreplay() || is_active() || is_stopping()) {
     server->find_idle_sessions();
+    server->evict_cap_revoke_non_responders();
     locker->tick();
   }
 
index 96e0b1c8bec451351bbfc4bd515ba5a68b1b5c04..0556e7cfdf58ec528e61a5eb285658eda1689664 100644 (file)
@@ -31,6 +31,7 @@
 #include "MDCache.h"
 #include "MDLog.h"
 #include "PurgeQueue.h"
+#include "Server.h"
 #include "osdc/Journaler.h"
 
 // Full .h import instead of forward declaration for PerfCounter, for the
@@ -101,7 +102,6 @@ namespace ceph {
   struct heartbeat_handle_d;
 }
 
-class Server;
 class Locker;
 class MDCache;
 class MDLog;
@@ -223,6 +223,7 @@ class MDSRank {
     void handle_conf_change(const struct md_config_t *conf,
                             const std::set <std::string> &changed)
     {
+      server->handle_conf_change(conf, changed);
       mdcache->handle_conf_change(conf, changed, *mdsmap);
       purge_queue.handle_conf_change(conf, changed, *mdsmap);
     }
index d8b7068b87cfdf2fa90b939c12152e7b14464469..8627081bf3c00fb13bbe138b5571e4457b57f6e3 100644 (file)
@@ -836,6 +836,36 @@ void Server::find_idle_sessions()
   }
 }
 
+void Server::evict_cap_revoke_non_responders() {
+  if (!cap_revoke_eviction_timeout) {
+    return;
+  }
+
+  std::list<client_t> to_evict;
+  mds->locker->get_late_revoking_clients(&to_evict, cap_revoke_eviction_timeout);
+
+  for (auto const &client: to_evict) {
+    mds->clog->warn() << "client id " << client << " has not responded to"
+                      << " cap revoke by MDS for over " << cap_revoke_eviction_timeout
+                      << " seconds, evicting";
+    dout(1) << __func__ << ": evicting cap revoke non-responder client id "
+            << client << dendl;
+
+    std::stringstream ss;
+    mds->evict_client(client.v, false, g_conf->mds_session_blacklist_on_evict,
+                      ss, nullptr);
+  }
+}
+
+void Server::handle_conf_change(const struct md_config_t *conf,
+                                const std::set <std::string> &changed) {
+  if (changed.count("mds_cap_revoke_eviction_timeout")) {
+    cap_revoke_eviction_timeout = g_conf->get_val<double>("mds_cap_revoke_eviction_timeout");
+    dout(20) << __func__ << " cap revoke eviction timeout changed to "
+            << cap_revoke_eviction_timeout << dendl;
+  }
+}
+
 /*
  * XXX bump in the interface here, not using an MDSInternalContextBase here
  * because all the callers right now happen to use a SaferCond
index 39a4dcc6683efe8437041c67b83c5d4532ce3e92..4133b7b50a5055db3c0b7be2fdfe3358d022a1f0 100644 (file)
@@ -90,6 +90,8 @@ private:
   feature_bitset_t supported_features;
   feature_bitset_t required_client_features;
 
+  double cap_revoke_eviction_timeout = 0;
+
   friend class MDSContinuation;
   friend class ServerContext;
   friend class ServerLogContext;
@@ -317,6 +319,10 @@ public:
                               CDentry *destdn, CDentry *staydn, map<client_t,MClientSnap*> splits[2],
                               bool finish_mdr);
 
+  void evict_cap_revoke_non_responders();
+  void handle_conf_change(const struct md_config_t *conf,
+                          const std::set <std::string> &changed);
+
 private:
   void reply_client_request(MDRequestRef& mdr, MClientReply *reply);
 };