]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
DecayCounter: take a utime_t in ::decode
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 21 Jun 2011 17:49:49 +0000 (10:49 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 21 Jun 2011 18:40:20 +0000 (11:40 -0700)
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 <colin.mccabe@dreamhost.com>
src/common/DecayCounter.h
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/mdstypes.h
src/messages/MHeartbeat.h

index 37769bec69476aa723784f1efa17a5ae17a56010..90afb61bc2d99600731b022595a2285b7adc8b05 100644 (file)
@@ -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
index bd00dfd5a759df6324470a524c11fc2a25d1d224..051c9ab4a7b41bf32ee2c941cda3f05b63d229be 100644 (file)
@@ -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);
index 92ac90194a64d09976981d08fe12e7e7ce47a14b..e53a93e1fba36ef65c3016a1f41a056e0ab3e607 100644 (file)
@@ -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())
index b1cb340b2b8abc158661a69af41d3baec1207dc5..cb8bb6e9443c53aa084c21f4c5988604a8bab7d6 100644 (file)
@@ -952,14 +952,17 @@ public:
     for (int i=0; i<NUM; i++)
       ::encode(vec[i], bl);
   }
-  void decode(bufferlist::iterator &p) {
+  void decode(const utime_t &t, bufferlist::iterator &p) {
     __u8 struct_v;
     ::decode(struct_v, p);
     for (int i=0; i<NUM; i++)
-      ::decode(vec[i], p);
+      ::decode(vec[i], t, p);
   }
 };
-WRITE_CLASS_ENCODER(inode_load_vec_t)
+inline void encode(const inode_load_vec_t &c, bufferlist &bl) { c.encode(bl); }
+inline void decode(inode_load_vec_t & c, const utime_t &t, bufferlist::iterator &p) {
+  c.decode(t, p);
+}
 
 class dirfrag_load_vec_t {
 public:
@@ -975,11 +978,11 @@ public:
     for (int i=0; i<NUM; i++)
       ::encode(vec[i], bl);
   }
-  void decode(bufferlist::iterator &p) {
+  void decode(const utime_t &t, bufferlist::iterator &p) {
     __u8 struct_v;
     ::decode(struct_v, p);
     for (int i=0; i<NUM; i++)
-      ::decode(vec[i], p);
+      ::decode(vec[i], t, p);
   }
 
   DecayCounter &get(int t) { 
@@ -1025,7 +1028,10 @@ public:
   }
 };
 
-WRITE_CLASS_ENCODER(dirfrag_load_vec_t)
+inline void encode(const dirfrag_load_vec_t &c, bufferlist &bl) { c.encode(bl); }
+inline void decode(dirfrag_load_vec_t& c, const utime_t &t, bufferlist::iterator &p) {
+  c.decode(t, p);
+}
 
 inline ostream& operator<<(ostream& out, dirfrag_load_vec_t& dl)
 {
@@ -1072,18 +1078,21 @@ struct mds_load_t {
     ::encode(queue_len, bl);
     ::encode(cpu_load_avg, bl);
   }
-  void decode(bufferlist::iterator &bl) {
+  void decode(const utime_t &t, bufferlist::iterator &bl) {
     __u8 struct_v;
     ::decode(struct_v, bl);
-    ::decode(auth, bl);
-    ::decode(all, bl);
+    ::decode(auth, t, bl);
+    ::decode(all, t, bl);
     ::decode(req_rate, bl);
     ::decode(cache_hit_rate, bl);
     ::decode(queue_len, bl);
     ::decode(cpu_load_avg, bl);
   }
 };
-WRITE_CLASS_ENCODER(mds_load_t)
+inline void encode(const mds_load_t &c, bufferlist &bl) { c.encode(bl); }
+inline void decode(mds_load_t &c, const utime_t &t, bufferlist::iterator &p) {
+  c.decode(t, p);
+}
 
 inline ostream& operator<<( ostream& out, mds_load_t& load )
 {
index 62a70919ab84cf914047f2581822b111585ce01d..4e71efb9dbb7181484654b54c9018d3d508ddaa0 100644 (file)
@@ -51,7 +51,8 @@ public:
   }
   void decode_payload(CephContext *cct) {
     bufferlist::iterator p = payload.begin();
-    ::decode(load, p);
+    utime_t now(ceph_clock_now(cct));
+    ::decode(load, now, p);
     ::decode(beat, p);
     ::decode(import_map, p);
   }