Skip to content

Commit

Permalink
mds: pass timeout argument for fetching late clients
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
vshankar committed Aug 21, 2018
1 parent 04b7d3d commit 005cf6c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/mds/Beacon.cc
Expand Up @@ -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) {
Expand Down
21 changes: 9 additions & 12 deletions src/mds/Locker.cc
Expand Up @@ -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()) {
Expand All @@ -3574,30 +3575,26 @@ 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;
}
}
}


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);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/mds/Locker.h
Expand Up @@ -188,8 +188,10 @@ class Locker {

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);
Expand Down

0 comments on commit 005cf6c

Please sign in to comment.