From 4e2a8fab147f577bb95b1291ea2e1f654a41193e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 24 Jun 2011 10:45:46 -0700 Subject: [PATCH] client: touch cap on lookup even if we use the dentry lease Touch the dir cap for the lease's mds even if we use the lease to traverse. This makes the trim_caps() behave better because it keeps the dentry and session cap LRUs in sync. Signed-off-by: Sage Weil --- src/client/Client.cc | 3 +++ src/client/Client.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 130ff18144728..f9806e1e04c87 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3319,6 +3319,9 @@ int Client::_lookup(Inode *dir, const string& dname, Inode **target) if (s->cap_ttl > now && s->cap_gen == dn->lease_gen) { *target = dn->inode; + // touch this mds's dir cap too, even though we don't _explicitly_ use it here, to + // make trim_caps() behave. + try_touch_cap(dir, dn->lease_mds); touch_dn(dn); goto done; } diff --git a/src/client/Client.h b/src/client/Client.h index 22fb8ca78159b..cd5ba72e28471 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -593,6 +593,10 @@ class Inode { // move to back of LRU cap->session->caps.push_back(&cap->cap_item); } + void try_touch_cap(Inode *inode, int mds) { + if (caps.count(mds)) + touch_cap[mds]; + } bool caps_issued_mask(unsigned mask) { int c = exporting_issued | snap_caps; if ((c & mask) == mask) -- 2.39.5