From: Jianpeng Ma Date: Wed, 8 Jul 2015 00:31:22 +0000 (+0800) Subject: common/TrackedOp: Make get_duration get correctly value. X-Git-Tag: v9.0.3~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5151%2Fhead;p=ceph.git common/TrackedOp: Make get_duration get correctly value. 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 --- diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index b2015b88f960..2f656cacb97e 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -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);