From 4615d1929baee4fdd28e53a3ae47e6962c73fccf Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 4 Jan 2008 18:16:51 -0800 Subject: [PATCH] cap stale -> resume works --- src/mds/CInode.cc | 2 +- src/mds/CInode.h | 13 +++++++++++++ src/mds/Locker.cc | 13 +++++++++---- src/mds/Server.cc | 2 +- src/messages/MClientSession.h | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index a1184a16b7556..463be08b4e3b3 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -82,7 +82,7 @@ ostream& operator<<(ostream& out, CInode& in) it != in.get_client_caps().end(); it++) { if (it != in.get_client_caps().begin()) out << ","; - out << it->first; + out << it->first << "=" << it->second->issued(); } out << "}"; } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index b5c67140ae5cd..8181be69c66ec 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -416,7 +416,20 @@ public: } return w; } + bool is_loner_cap() { + if (!mds_caps_wanted.empty()) + return false; + int n = 0; + for (map::iterator it = client_caps.begin(); + it != client_caps.end(); + it++) + if (!it->second->is_stale()) { + if (n) return false; + n++; + } + return (n == 1); + } void replicate_relax_locks() { //dout(10) << " relaxing locks on " << *this << dendl; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 99e646004a2a7..e11c0ca619938 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -572,9 +572,13 @@ void Locker::revoke_stale_caps(Session *session) if (issued) { dout(10) << " revoking " << cap_string(issued) << " on " << *in << dendl; cap->revoke(); - file_eval(&in->filelock); - if (!in->is_auth()) + file_eval_gather(&in->filelock); + if (in->is_auth()) { + if (in->filelock.is_stable()) + file_eval(&in->filelock); + } else { request_inode_file_caps(in); + } } else { dout(10) << " nothing issued on " << *in << dendl; } @@ -592,7 +596,8 @@ void Locker::resume_stale_caps(Session *session) if (cap->is_stale()) { dout(10) << " clearing stale flag on " << *in << dendl; cap->set_stale(false); - file_eval(&in->filelock); + if (in->is_auth() && in->filelock.is_stable()) + file_eval(&in->filelock); issue_caps(in); } } @@ -2447,7 +2452,7 @@ void Locker::file_eval(FileLock *lock) { CInode *in = (CInode*)lock->get_parent(); int wanted = in->get_caps_wanted(); - bool loner = (in->client_caps.size() == 1) && in->mds_caps_wanted.empty(); + bool loner = in->is_loner_cap(); dout(7) << "file_eval wanted=" << cap_string(wanted) << " filelock=" << *lock << " on " << *lock->get_parent() << " loner=" << loner diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5c8acec58ca37..ef3a053a542c9 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -314,7 +314,7 @@ void Server::find_idle_sessions() dout(10) << "new stale session " << session->inst << " last " << session->last_cap_renew << dendl; mds->sessionmap.set_state(session, Session::STATE_STALE); mds->locker->revoke_stale_caps(session); - mds->messenger->send_message(new MClientSession(CEPH_SESSION_STALE, g_clock.now()), + mds->messenger->send_message(new MClientSession(CEPH_SESSION_STALE, session->get_push_seq()), session->inst); } diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index 7c709c9639f63..16a35ee1cdca3 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -35,7 +35,7 @@ public: } int32_t op; - version_t seq; // used when requesting close only + version_t seq; // used when requesting close, declaring stale utime_t stamp; MClientSession() : Message(CEPH_MSG_CLIENT_SESSION) { } -- 2.39.5