]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/TrackedOp: Make get_duration get correctly value. 5151/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Wed, 8 Jul 2015 00:31:22 +0000 (08:31 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Wed, 8 Jul 2015 01:01:19 +0000 (09:01 +0800)
For get_duration(), it should return the duration of Op. For ops which in
flight, the duration is the time current time subtrace the
initiated_time. For the completed Ops, it used the last event(done)
subtrace the initiated_time.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/TrackedOp.h

index b2015b88f9604fac0c0215d16bf6d1a9ba30a44b..2f656cacb97e4187915b2a39e463840f007f2ddf 100644 (file)
@@ -180,11 +180,12 @@ public:
   const utime_t& get_initiated() const {
     return initiated_at;
   }
-  // This function maybe needs some work; assumes last event is completion time
+
   double get_duration() const {
-    return events.empty() ?
-      0.0 :
-      (events.rbegin()->first - get_initiated());
+    if (!events.empty() && events.rbegin()->second.compare("done") == 0)
+      return events.rbegin()->first - get_initiated();
+    else
+      return ceph_clock_now(NULL) - get_initiated();
   }
 
   void mark_event(const string &event);