]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix op event duration calculation 42315/head
authorJonas Jelten <jj@sft.lol>
Tue, 13 Jul 2021 17:02:53 +0000 (19:02 +0200)
committerJonas Jelten <jj@sft.lol>
Tue, 13 Jul 2021 17:09:41 +0000 (19:09 +0200)
Each event is recorded with the timestamp when it's done.
Thus the time the event took is `event_timestamp - prev_event_timestamp`,
and not `next_event_timestamp - event_timestamp`, since that would be the next
event's duration.

This off-by-one is fixed by the patch.

Signed-off-by: Jonas Jelten <jj@sft.lol>
src/osd/OpRequest.cc

index 0eb92c23a6a3e2642d1c033203cd8d6218e46821..cd62c922d6d45b96e9c9f9889400a2ef9c5f5cfd 100644 (file)
@@ -74,14 +74,14 @@ void OpRequest::_dump(Formatter *f) const
       f->dump_string("event", i->str);
       f->dump_stream("time") << i->stamp;
 
-      auto i_next = i + 1;
+      double duration = 0;
 
-      if (i_next < events.end()) {
-       f->dump_float("duration", i_next->stamp - i->stamp);
-      } else {
-       f->dump_float("duration", events.rbegin()->stamp - get_initiated());
+      if (i != events.begin()) {
+        auto i_prev = i - 1;
+        duration = i->stamp - i_prev->stamp;
       }
 
+      f->dump_float("duration", duration);
       f->close_section();
     }
     f->close_section();