]> git.apps.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>
Tue, 21 Aug 2018 05:58:55 +0000 (01:58 -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>
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 7d52edd0a47fc8136a3d3845424402c7dea9f489..d9fdc8315b177e112fc54108a18ee7b52c3f9cf3 100644 (file)
@@ -7177,6 +7177,10 @@ std::vector<Option> get_mds_options() {
     Option("mds_request_load_average_decay_rate", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
     .set_default(60)
     .set_description("rate of decay in seconds for calculating request load average"),
+
+    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 33144d267a543ca5647ed7a02e3a12e683653c00..164a1fea7f976818f6da94979b95099046a516b9 100644 (file)
@@ -361,6 +361,7 @@ const char** MDSDaemon::get_tracked_conf_keys() const
     "host",
     "fsid",
     "mds_request_load_average_decay_rate",
+    "mds_cap_revoke_eviction_timeout",
     NULL
   };
   return KEYS;
index a8b78664764b2af2c29c0582514c28eb14a10d74..818ae454b31a0f86a25e79e6ed577eff72539fc8 100644 (file)
@@ -28,7 +28,6 @@
 #include "MDBalancer.h"
 #include "Migrator.h"
 #include "Locker.h"
-#include "Server.h"
 #include "InoTable.h"
 #include "mon/MonClient.h"
 #include "common/HeartbeatMap.h"
@@ -321,6 +320,7 @@ void MDSRankDispatcher::tick()
   // ...
   if (is_clientreplay() || is_active() || is_stopping()) {
     server->find_idle_sessions();
+    server->evict_cap_revoke_non_responders();
     locker->tick();
   }
 
index 86b9c76022d0fcefa1c9c3fe088bea66c1e5f180..660a40a4842f1daee1e573b6d499c3d522faa1b8 100644 (file)
@@ -34,6 +34,7 @@
 #include "MDLog.h"
 #include "MDSContext.h"
 #include "PurgeQueue.h"
+#include "Server.h"
 #include "osdc/Journaler.h"
 
 // Full .h import instead of forward declaration for PerfCounter, for the
@@ -104,7 +105,6 @@ namespace ceph {
   struct heartbeat_handle_d;
 }
 
-class Server;
 class Locker;
 class MDCache;
 class MDLog;
@@ -226,6 +226,7 @@ class MDSRank {
                             const std::set <std::string> &changed)
     {
       sessionmap.handle_conf_change(conf, changed);
+      server->handle_conf_change(conf, changed);
       mdcache->handle_conf_change(conf, changed, *mdsmap);
       purge_queue.handle_conf_change(conf, changed, *mdsmap);
     }
index e15c46ead141741e02bdaed9dcec601e9fa3b026..21e59f263f998a148123008748fcb0a339e19faa 100644 (file)
@@ -826,6 +826,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 ConfigProxy& 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 d848bd6cab270d47fae102c8890a5ee564248f44..36bbbbbe51c1027e9483c5491ee9f8b38a4a4ae4 100644 (file)
@@ -95,6 +95,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;
@@ -319,6 +321,10 @@ public:
                               CDentry *destdn, CDentry *staydn, map<client_t,MClientSnap::ref> splits[2],
                               bool finish_mdr);
 
+  void evict_cap_revoke_non_responders();
+  void handle_conf_change(const ConfigProxy& conf,
+                          const std::set <std::string> &changed);
+
 private:
   void reply_client_request(MDRequestRef& mdr, const MClientReply::ref &reply);
 };