From b64a48b7ef5712755417133d6a58102e12137783 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Tue, 21 Jun 2011 10:49:49 -0700 Subject: [PATCH] DecayCounter: take a utime_t in ::decode We need to initialize the last_decay time of the DecayCounter when decoding it. This is not found in the encoded information, but instead is set to the current time. We need to pass this in explicitly now because of deglobalization. This also reduces the number of calls to gettimeofday, which is good in general. Signed-off-by: Colin McCabe --- src/common/DecayCounter.h | 7 +++++-- src/mds/CDir.cc | 4 ++-- src/mds/CInode.cc | 2 +- src/mds/mdstypes.h | 29 +++++++++++++++++++---------- src/messages/MHeartbeat.h | 3 ++- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/common/DecayCounter.h b/src/common/DecayCounter.h index 37769bec69476..90afb61bc2d99 100644 --- a/src/common/DecayCounter.h +++ b/src/common/DecayCounter.h @@ -58,7 +58,7 @@ public: ::encode(delta, bl); ::encode(vel, bl); } - void decode(bufferlist::iterator &p) { + void decode(const utime_t &t, bufferlist::iterator &p) { __u8 struct_v; ::decode(struct_v, p); if (struct_v < 2) { @@ -152,7 +152,10 @@ public: } }; -WRITE_CLASS_ENCODER(DecayCounter) +inline void encode(const DecayCounter &c, bufferlist &bl) { c.encode(bl); } +inline void decode(DecayCounter &c, const utime_t &t, bufferlist::iterator &p) { + c.decode(t, p); +} #endif diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index bd00dfd5a759d..051c9ab4a7b41 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2134,8 +2134,8 @@ void CDir::decode_import(bufferlist::iterator& blp, utime_t now) ::decode(dir_rep, blp); - ::decode(pop_me, blp); - ::decode(pop_auth_subtree, blp); + ::decode(pop_me, now, blp); + ::decode(pop_auth_subtree, now, blp); pop_auth_subtree_nested.add(now, cache->decayrate, pop_auth_subtree); ::decode(dir_rep_by, blp); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 92ac90194a64d..e53a93e1fba36 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -2654,7 +2654,7 @@ void CInode::decode_import(bufferlist::iterator& p, if (dirty) _mark_dirty(ls); - ::decode(pop, p); + ::decode(pop, ceph_clock_now(&g_ceph_context), p); ::decode(replica_map, p); if (!replica_map.empty()) diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index b1cb340b2b8ab..cb8bb6e9443c5 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -952,14 +952,17 @@ public: for (int i=0; i