]> git.apps.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>
Tue, 21 Aug 2018 05:58:55 +0000 (01:58 -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>
src/mds/Beacon.cc
src/mds/Locker.cc
src/mds/Locker.h

index a7e0a9fc8fa7eb35ef21b4104d5092a5491d6fee..fd72603af32c29b2b02837086aaf894291c40673 100644 (file)
@@ -351,7 +351,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 5c6e22c07f1561f3ea4d78c8dc7e8fe26295319c..affb7ae2d12575e60b0fa3e056eeacfc02a80eaf 100644 (file)
@@ -3565,7 +3565,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()) {
@@ -3574,7 +3575,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;
@@ -3582,22 +3583,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 c5fb9d9f3c4b970cf81aa2babde6f1381c9a69ab..1678f5c01047638c050f7f3023639367b04c4366 100644 (file)
@@ -188,8 +188,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);