]> 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)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 1 Oct 2018 21:37:19 +0000 (14:37 -0700)
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)

Conflicts:
src/mds/Locker.cc

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

index e64549bd762501d711b6fbd80bb21e092bae1bf9..3f2738063a6f9a282e06899440774f1351f5d10a 100644 (file)
@@ -361,7 +361,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 251dad5ff37d8c64ccc06b932210dca39f255e06..47197b5f170dd1b556c3ff2fc24ff6afdc7da555 100644 (file)
@@ -3529,7 +3529,8 @@ void Locker::remove_client_cap(CInode *in, client_t client)
  * Return true if any currently revoking caps exceed the
  * mds_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()) {
@@ -3538,7 +3539,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 <= g_conf->mds_session_timeout) {
+      if (age <= timeout) {
           return false;
       } else {
           return true;
@@ -3546,22 +3547,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 350264e935958348f13db5bb587001168457b2aa..f0a9a4ce40c092334249ce32e85b07108ebc7318 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);