Skip to content

Commit 8d728c7

Browse files
vshankaridryomov
authored andcommitted
ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
Latencies are of type ktime_t, coverting from jiffies is incorrect. Also, switch to "struct ceph_timespec" for r/w/m latencies. Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 1ad3bb2 commit 8d728c7

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

fs/ceph/metric.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include "metric.h"
99
#include "mds_client.h"
1010

11+
static void ktime_to_ceph_timespec(struct ceph_timespec *ts, ktime_t val)
12+
{
13+
struct timespec64 t = ktime_to_timespec64(val);
14+
ceph_encode_timespec64(ts, &t);
15+
}
16+
1117
static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
1218
struct ceph_mds_session *s)
1319
{
@@ -26,7 +32,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
2632
u64 nr_caps = atomic64_read(&m->total_caps);
2733
u32 header_len = sizeof(struct ceph_metric_header);
2834
struct ceph_msg *msg;
29-
struct timespec64 ts;
3035
s64 sum;
3136
s32 items = 0;
3237
s32 len;
@@ -63,9 +68,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
6368
read->header.compat = 1;
6469
read->header.data_len = cpu_to_le32(sizeof(*read) - header_len);
6570
sum = m->metric[METRIC_READ].latency_sum;
66-
jiffies_to_timespec64(sum, &ts);
67-
read->sec = cpu_to_le32(ts.tv_sec);
68-
read->nsec = cpu_to_le32(ts.tv_nsec);
71+
ktime_to_ceph_timespec(&read->lat, sum);
6972
items++;
7073

7174
/* encode the write latency metric */
@@ -75,9 +78,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
7578
write->header.compat = 1;
7679
write->header.data_len = cpu_to_le32(sizeof(*write) - header_len);
7780
sum = m->metric[METRIC_WRITE].latency_sum;
78-
jiffies_to_timespec64(sum, &ts);
79-
write->sec = cpu_to_le32(ts.tv_sec);
80-
write->nsec = cpu_to_le32(ts.tv_nsec);
81+
ktime_to_ceph_timespec(&write->lat, sum);
8182
items++;
8283

8384
/* encode the metadata latency metric */
@@ -87,9 +88,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
8788
meta->header.compat = 1;
8889
meta->header.data_len = cpu_to_le32(sizeof(*meta) - header_len);
8990
sum = m->metric[METRIC_METADATA].latency_sum;
90-
jiffies_to_timespec64(sum, &ts);
91-
meta->sec = cpu_to_le32(ts.tv_sec);
92-
meta->nsec = cpu_to_le32(ts.tv_nsec);
91+
ktime_to_ceph_timespec(&meta->lat, sum);
9392
items++;
9493

9594
/* encode the dentry lease metric */

fs/ceph/metric.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef _FS_CEPH_MDS_METRIC_H
33
#define _FS_CEPH_MDS_METRIC_H
44

5-
#include <linux/types.h>
5+
#include <linux/ceph/types.h>
66
#include <linux/percpu_counter.h>
77
#include <linux/ktime.h>
88

@@ -60,22 +60,19 @@ struct ceph_metric_cap {
6060
/* metric read latency header */
6161
struct ceph_metric_read_latency {
6262
struct ceph_metric_header header;
63-
__le32 sec;
64-
__le32 nsec;
63+
struct ceph_timespec lat;
6564
} __packed;
6665

6766
/* metric write latency header */
6867
struct ceph_metric_write_latency {
6968
struct ceph_metric_header header;
70-
__le32 sec;
71-
__le32 nsec;
69+
struct ceph_timespec lat;
7270
} __packed;
7371

7472
/* metric metadata latency header */
7573
struct ceph_metric_metadata_latency {
7674
struct ceph_metric_header header;
77-
__le32 sec;
78-
__le32 nsec;
75+
struct ceph_timespec lat;
7976
} __packed;
8077

8178
/* metric dentry lease header */

0 commit comments

Comments
 (0)