xref: /openbmc/linux/fs/ceph/metric.h (revision 82df5b73)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _FS_CEPH_MDS_METRIC_H
3 #define _FS_CEPH_MDS_METRIC_H
4 
5 #include <linux/types.h>
6 #include <linux/percpu_counter.h>
7 #include <linux/ktime.h>
8 
9 /* This is the global metrics */
10 struct ceph_client_metric {
11 	atomic64_t            total_dentries;
12 	struct percpu_counter d_lease_hit;
13 	struct percpu_counter d_lease_mis;
14 
15 	struct percpu_counter i_caps_hit;
16 	struct percpu_counter i_caps_mis;
17 
18 	spinlock_t read_latency_lock;
19 	u64 total_reads;
20 	ktime_t read_latency_sum;
21 	ktime_t read_latency_sq_sum;
22 	ktime_t read_latency_min;
23 	ktime_t read_latency_max;
24 
25 	spinlock_t write_latency_lock;
26 	u64 total_writes;
27 	ktime_t write_latency_sum;
28 	ktime_t write_latency_sq_sum;
29 	ktime_t write_latency_min;
30 	ktime_t write_latency_max;
31 
32 	spinlock_t metadata_latency_lock;
33 	u64 total_metadatas;
34 	ktime_t metadata_latency_sum;
35 	ktime_t metadata_latency_sq_sum;
36 	ktime_t metadata_latency_min;
37 	ktime_t metadata_latency_max;
38 };
39 
40 extern int ceph_metric_init(struct ceph_client_metric *m);
41 extern void ceph_metric_destroy(struct ceph_client_metric *m);
42 
43 static inline void ceph_update_cap_hit(struct ceph_client_metric *m)
44 {
45 	percpu_counter_inc(&m->i_caps_hit);
46 }
47 
48 static inline void ceph_update_cap_mis(struct ceph_client_metric *m)
49 {
50 	percpu_counter_inc(&m->i_caps_mis);
51 }
52 
53 extern void ceph_update_read_latency(struct ceph_client_metric *m,
54 				     ktime_t r_start, ktime_t r_end,
55 				     int rc);
56 extern void ceph_update_write_latency(struct ceph_client_metric *m,
57 				      ktime_t r_start, ktime_t r_end,
58 				      int rc);
59 extern void ceph_update_metadata_latency(struct ceph_client_metric *m,
60 				         ktime_t r_start, ktime_t r_end,
61 					 int rc);
62 #endif /* _FS_CEPH_MDS_METRIC_H */
63