From 60596c75a186587ee62e6b587890e9ccdc9abf06 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 17 Aug 2010 12:16:02 -0700 Subject: [PATCH] mds: drop x/wrlocks before, rdlocks after sending reply This lets us issue the most leases/caps possible. It also ensure we can issue caps in the snapped namespace when we are still on the head inode (previously, releasing the rdlock twiddled the state, the client didn't get say Frc, and hung indefinitely). --- src/mds/Locker.cc | 8 ++++++++ src/mds/Locker.h | 1 + src/mds/Server.cc | 12 +++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 98b8ffb89d674..cdd84a0d620ee 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -389,6 +389,14 @@ void Locker::drop_locks(Mutation *mut) mut->done_locking = false; } +void Locker::drop_non_rdlocks(Mutation *mut) +{ + while (!mut->xlocks.empty()) + xlock_finish(*mut->xlocks.begin(), mut); + while (!mut->wrlocks.empty()) + wrlock_finish(*mut->wrlocks.begin(), mut); +} + void Locker::drop_rdlocks(Mutation *mut) { while (!mut->rdlocks.empty()) diff --git a/src/mds/Locker.h b/src/mds/Locker.h index 248f018814e7f..4a0be64416347 100644 --- a/src/mds/Locker.h +++ b/src/mds/Locker.h @@ -87,6 +87,7 @@ public: void drop_locks(Mutation *mut); void set_xlocks_done(Mutation *mut); + void drop_non_rdlocks(Mutation *mut); void drop_rdlocks(Mutation *mut); void eval_gather(SimpleLock *lock, bool first=false, bool *need_issue=0, list *pfinishers=0); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 2bde1fb03a434..4b207d5f4f25c 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -880,11 +880,8 @@ void Server::reply_request(MDRequest *mdr, MClientReply *reply, CInode *tracei, Connection *client_con = req->get_connection(); client_con->get(); - // clean up request, drop locks, etc. - // do this before replying, so that we can issue leases - mdcache->request_finish(mdr); - mdr = 0; - req = 0; + // drop non-rdlocks before replying, so that we can issue leases + mds->locker->drop_non_rdlocks(mdr); // reply at all? if (client_inst.name.is_mds()) { @@ -908,6 +905,11 @@ void Server::reply_request(MDRequest *mdr, MClientReply *reply, CInode *tracei, } client_con->put(); + // clean up request + mdcache->request_finish(mdr); + mdr = 0; + req = 0; + // take a closer look at tracei, if it happens to be a remote link if (tracei && tracei->get_parent_dn() && -- 2.39.5