From 16306d7bd04b9d1a332b1a05f693a2aee7c065bf Mon Sep 17 00:00:00 2001 From: Mohamad Gebai Date: Tue, 23 Jan 2018 11:00:53 -0500 Subject: [PATCH] librbd: use steady clock to measure elapsed time in AioCompletion Signed-off-by: Mohamad Gebai --- src/librbd/internal.cc | 7 ++++--- src/librbd/internal.h | 1 + src/librbd/io/AioCompletion.cc | 5 ++--- src/librbd/io/AioCompletion.h | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2efccda9cd2..50e8718cae0 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -2150,7 +2150,8 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) int (*cb)(uint64_t, size_t, const char *, void *), void *arg) { - utime_t start_time, elapsed; + coarse_mono_time start_time; + ceph::timespan elapsed; ldout(ictx->cct, 20) << "read_iterate " << ictx << " off = " << off << " len = " << len << dendl; @@ -2176,7 +2177,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) } RWLock::RLocker owner_locker(ictx->owner_lock); - start_time = ceph_clock_now(); + start_time = coarse_mono_clock::now(); while (left > 0) { uint64_t period_off = off - (off % period); uint64_t read_len = min(period_off + period - off, left); @@ -2204,7 +2205,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) off += ret; } - elapsed = ceph_clock_now() - start_time; + elapsed = coarse_mono_clock::now() - start_time; ictx->perfcounter->tinc(l_librbd_rd_latency, elapsed); ictx->perfcounter->inc(l_librbd_rd); ictx->perfcounter->inc(l_librbd_rd_bytes, mylen); diff --git a/src/librbd/internal.h b/src/librbd/internal.h index cf5389caed1..d054e8dbe4f 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -15,6 +15,7 @@ #include "include/rbd_types.h" #include "cls/rbd/cls_rbd_types.h" #include "common/WorkQueue.h" +#include "common/ceph_time.h" #include "librbd/Types.h" namespace librbd { diff --git a/src/librbd/io/AioCompletion.cc b/src/librbd/io/AioCompletion.cc index e30a083e136..ef51ad36cc4 100644 --- a/src/librbd/io/AioCompletion.cc +++ b/src/librbd/io/AioCompletion.cc @@ -57,8 +57,7 @@ void AioCompletion::complete() { CephContext *cct = ictx->cct; tracepoint(librbd, aio_complete_enter, this, rval); - utime_t elapsed; - elapsed = ceph_clock_now() - start_time; + ceph::timespan elapsed = coarse_mono_clock::now() - start_time; switch (aio_type) { case AIO_TYPE_GENERIC: case AIO_TYPE_OPEN: @@ -116,7 +115,7 @@ void AioCompletion::init_time(ImageCtx *i, aio_type_t t) { if (ictx == nullptr) { ictx = i; aio_type = t; - start_time = ceph_clock_now(); + start_time = coarse_mono_clock::now(); } } diff --git a/src/librbd/io/AioCompletion.h b/src/librbd/io/AioCompletion.h index a3edb141423..e0b07cc6ef2 100644 --- a/src/librbd/io/AioCompletion.h +++ b/src/librbd/io/AioCompletion.h @@ -6,6 +6,7 @@ #include "common/Cond.h" #include "common/Mutex.h" +#include "common/ceph_time.h" #include "include/Context.h" #include "include/utime.h" #include "include/rbd/librbd.hpp" @@ -53,7 +54,7 @@ struct AioCompletion { int ref; bool released; ImageCtx *ictx; - utime_t start_time; + coarse_mono_time start_time; aio_type_t aio_type; ReadResult read_result; -- 2.39.5