]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: pass timeout argument for fetching late clients
authorVenky Shankar <vshankar@redhat.com>
Fri, 3 Aug 2018 11:11:09 +0000 (07:11 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 18 Oct 2018 12:36:13 +0000 (08:36 -0400)
This would be required when fetching clients that have not
responded to cap revoke by MDS for a configured timeout
value.

Additionally, make member functions private which are called
from the Locker class itself.

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

src/mds/Beacon.cc
src/mds/Locker.cc
src/mds/Locker.h

index b85da2c3a41403bc1ae4f6d8f008b655085fa1f2..2ef957c6aab5e8c0b123b5fe0833f9228686334f 100644 (file)
@@ -359,7 +359,8 @@ void Beacon::notify_health(MDSRank const *mds)
   // CLIENT_CAPS messages.
   {
     std::list<client_t> late_clients;
-    mds->locker->get_late_revoking_clients(&late_clients);
+    mds->locker->get_late_revoking_clients(&late_clients,
+                                           mds->mdsmap->get_session_timeout());
     std::list<MDSHealthMetric> late_cap_metrics;
 
     for (std::list<client_t>::iterator i = late_clients.begin(); i != late_clients.end(); ++i) {
index c160e31cbf025542d830d299ab4ea164774f084b..683f86e19d15f0635eef2806eee530bd8151c5e2 100644 (file)
@@ -3599,7 +3599,8 @@ void Locker::remove_client_cap(CInode *in, client_t client)
  * Return true if any currently revoking caps exceed the
  * session_timeout threshold.
  */
-bool Locker::any_late_revoking_caps(xlist<Capability*> const &revoking) const
+bool Locker::any_late_revoking_caps(xlist<Capability*> const &revoking,
+                                    double timeout) const
 {
     xlist<Capability*>::const_iterator p = revoking.begin();
     if (p.end()) {
@@ -3608,7 +3609,7 @@ bool Locker::any_late_revoking_caps(xlist<Capability*> const &revoking) const
     } else {
       utime_t now = ceph_clock_now();
       utime_t age = now - (*p)->get_last_revoke_stamp();
-      if (age <= mds->mdsmap->get_session_timeout()) {
+      if (age <= timeout) {
           return false;
       } else {
           return true;
@@ -3616,22 +3617,18 @@ bool Locker::any_late_revoking_caps(xlist<Capability*> const &revoking) const
     }
 }
 
-
-void Locker::get_late_revoking_clients(std::list<client_t> *result) const
+void Locker::get_late_revoking_clients(std::list<client_t> *result,
+                                       double timeout) const
 {
-  if (!any_late_revoking_caps(revoking_caps)) {
+  if (!any_late_revoking_caps(revoking_caps, timeout)) {
     // Fast path: no misbehaving clients, execute in O(1)
     return;
   }
 
   // Slow path: execute in O(N_clients)
-  std::map<client_t, xlist<Capability*> >::const_iterator client_rc_iter;
-  for (client_rc_iter = revoking_caps_by_client.begin();
-       client_rc_iter != revoking_caps_by_client.end(); ++client_rc_iter) {
-    xlist<Capability*> const &client_rc = client_rc_iter->second;
-    bool any_late = any_late_revoking_caps(client_rc);
-    if (any_late) {
-        result->push_back(client_rc_iter->first);
+  for (auto &p : revoking_caps_by_client) {
+    if (any_late_revoking_caps(p.second, timeout)) {
+      result->push_back(p.first);
     }
   }
 }
index f3dd5ca516486660c606cefa68e7c4c2297768a6..1be1a1e783aac456f3df689891d08bb16b3a95de 100644 (file)
@@ -186,8 +186,10 @@ public:
 
   void remove_client_cap(CInode *in, client_t client);
 
-  void get_late_revoking_clients(std::list<client_t> *result) const;
-  bool any_late_revoking_caps(xlist<Capability*> const &revoking) const;
+  void get_late_revoking_clients(std::list<client_t> *result, double timeout) const;
+
+private:
+  bool any_late_revoking_caps(xlist<Capability*> const &revoking, double timeout) const;
 
 protected:
   bool _need_flush_mdlog(CInode *in, int wanted_caps);