summaryrefslogtreecommitdiff
path: root/fs/ceph/metric.c
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2020-03-19 23:45:02 -0400
committerIlya Dryomov <idryomov@gmail.com>2020-06-01 13:22:51 +0200
commit70c948206f0616c7e46130a26165b6a5d98bade4 (patch)
treee494d909a6cff5bbffd2404ba5188ed46af2fbd8 /fs/ceph/metric.c
parent97e27aaa9a2cbd6238c66b3251d397e0eacc9968 (diff)
ceph: add metadata perf metric support
Add a new "r_ended" field to struct ceph_mds_request and use that to maintain the average latency of MDS requests. URL: https://tracker.ceph.com/issues/43215 Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/metric.c')
-rw-r--r--fs/ceph/metric.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
index f5cf32e7789f..9217f35bc2b9 100644
--- a/fs/ceph/metric.c
+++ b/fs/ceph/metric.c
@@ -44,6 +44,13 @@ int ceph_metric_init(struct ceph_client_metric *m)
m->total_writes = 0;
m->write_latency_sum = 0;
+ spin_lock_init(&m->metadata_latency_lock);
+ m->metadata_latency_sq_sum = 0;
+ m->metadata_latency_min = KTIME_MAX;
+ m->metadata_latency_max = 0;
+ m->total_metadatas = 0;
+ m->metadata_latency_sum = 0;
+
return 0;
err_i_caps_mis:
@@ -123,3 +130,19 @@ void ceph_update_write_latency(struct ceph_client_metric *m,
&m->write_latency_sq_sum, lat);
spin_unlock(&m->write_latency_lock);
}
+
+void ceph_update_metadata_latency(struct ceph_client_metric *m,
+ ktime_t r_start, ktime_t r_end,
+ int rc)
+{
+ ktime_t lat = ktime_sub(r_end, r_start);
+
+ if (unlikely(rc && rc != -ENOENT))
+ return;
+
+ spin_lock(&m->metadata_latency_lock);
+ __update_latency(&m->total_metadatas, &m->metadata_latency_sum,
+ &m->metadata_latency_min, &m->metadata_latency_max,
+ &m->metadata_latency_sq_sum, lat);
+ spin_unlock(&m->metadata_latency_lock);
+}