From 6593650d1acbefadeb985ed5062cf5a45bab2fd3 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Thu, 23 Jul 2020 01:20:38 -0400 Subject: [PATCH] client: track cap hits and misses globally Signed-off-by: Venky Shankar --- src/client/Client.cc | 5 +++++ src/client/Client.h | 13 +++++++++++++ src/client/Inode.cc | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 1e884075220f..d9c0bb0d2708 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3230,6 +3230,10 @@ void Client::put_cap_ref(Inode *in, int cap) } } +// get caps for a given file handle -- the inode should have @need caps +// issued by the mds and @want caps not revoked (or not under revocation). +// this routine blocks till the cap requirement is satisfied. also account +// (track) for capability hit when required (when cap requirement succeedes). int Client::get_caps(Fh *fh, int need, int want, int *phave, loff_t endoff) { Inode *in = fh->inode.get(); @@ -3304,6 +3308,7 @@ int Client::get_caps(Fh *fh, int need, int want, int *phave, loff_t endoff) if ((revoking & want) == 0) { *phave = need | (have & want); in->get_cap_ref(need); + cap_hit(); return 0; } } diff --git a/src/client/Client.h b/src/client/Client.h index 15bf6a9cd8db..002357a3ee59 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -732,6 +732,16 @@ public: void flush_cap_releases(); void tick(); + void cap_hit() { + ++cap_hits; + } + void cap_miss() { + ++cap_misses; + } + std::pair get_cap_hit_rates() { + return std::make_pair(cap_hits, cap_misses); + } + xlist &get_dirty_list() { return dirty_list; } SafeTimer timer; @@ -1281,6 +1291,9 @@ private: int reclaim_errno = 0; epoch_t reclaim_osd_epoch = 0; entity_addrvec_t reclaim_target_addrs; + + uint64_t cap_hits = 0; + uint64_t cap_misses = 0; }; /** diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 2b7738adf4a5..ab27d1eb4f11 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -232,6 +232,7 @@ void Inode::try_touch_cap(mds_rank_t mds) * This is the bog standard "check whether we have the required caps" operation. * Typically, we only check against the capset that is currently "issued". * In other words, we ignore caps that have been revoked but not yet released. + * Also account capability hit/miss stats. * * Some callers (particularly those doing attribute retrieval) can also make * use of the full set of "implemented" caps to satisfy requests from the @@ -252,6 +253,7 @@ bool Inode::caps_issued_mask(unsigned mask, bool allow_impl) cap_is_valid(*auth_cap) && (auth_cap->issued & mask) == mask) { auth_cap->touch(); + client->cap_hit(); return true; } // try any cap @@ -260,6 +262,7 @@ bool Inode::caps_issued_mask(unsigned mask, bool allow_impl) if (cap_is_valid(cap)) { if ((cap.issued & mask) == mask) { cap.touch(); + client->cap_hit(); return true; } c |= cap.issued; @@ -275,8 +278,11 @@ bool Inode::caps_issued_mask(unsigned mask, bool allow_impl) for (auto &pair : caps) { pair.second.touch(); } + client->cap_hit(); return true; } + + client->cap_miss(); return false; } -- 2.47.3