ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
PATCH 1/1 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.
--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)
fs/ceph/metric.c +10 -10
@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val) +{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec); +} +static bool ceph_mdsc_send_metrics (struct ceph_mds_client *mdsc,struct ceph_mds_session *s) {
@@ -26,7 +33,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,u64 nr_caps =atomic64_read (&m->total_caps);u32 header_len =sizeof (struct ceph_metric_header );struct ceph_msg *msg; -struct timespec64 ts;s64 sum;s32 items =0 ;s32 len;
@@ -63,9 +69,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->header.compat =1 ; read->header.data_len =cpu_to_le32 (sizeof (*read) - header_len); sum = m->metric[METRIC_READ ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - read->sec =cpu_to_le32 (ts.tv_sec); - read->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&read->lat, sum); items++;/* encode the write latency metric */
@@ -75,9 +79,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->header.compat =1 ; write->header.data_len =cpu_to_le32 (sizeof (*write) - header_len); sum = m->metric[METRIC_WRITE ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - write->sec =cpu_to_le32 (ts.tv_sec); - write->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&write->lat, sum); items++;/* encode the metadata latency metric */
@@ -87,9 +89,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->header.compat =1 ; meta->header.data_len =cpu_to_le32 (sizeof (*meta) - header_len); sum = m->metric[METRIC_METADATA ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - meta->sec =cpu_to_le32 (ts.tv_sec); - meta->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&meta->lat, sum); items++;/* encode the dentry lease metric */
fs/ceph/metric.h +4 -7
@@ -2,7 +2,7 @@#ifndef _FS_CEPH_MDS_METRIC_H#define _FS_CEPH_MDS_METRIC_H -#include <linux/types.h> +#include <linux/ceph/types.h> #include <linux/percpu_counter.h> #include <linux/ktime.h>
@@ -60,22 +60,19 @@ struct ceph_metric_cap {/* metric read latency header */ struct ceph_metric_read_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric write latency header */ struct ceph_metric_write_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric metadata latency header */ struct ceph_metric_metadata_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric dentry lease header */
Signature · 1 line
2.27.0
Quoted 97 lines · Venky Shankar
Latencies are of type
ktime_t, coverting from jiffies is incorrect. Also, switch to "structceph_timespec" for r/w/m latencies.Signed-off-by Venky Shankar <[email protected]>--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)fs/ceph/metric.c +10
-10@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val) +{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec); +} +static bool ceph_mdsc_send_metrics (struct ceph_mds_client *mdsc,struct ceph_mds_session *s) {@@ -26,7 +33,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,u64 nr_caps =atomic64_read (&m->total_caps);u32 header_len =sizeof (struct ceph_metric_header );struct ceph_msg *msg; -struct timespec64 ts;s64 sum;s32 items =0 ;s32 len;@@ -63,9 +69,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->header.compat =1 ; read->header.data_len =cpu_to_le32 (sizeof (*read) - header_len); sum = m->metric[METRIC_READ ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - read->sec =cpu_to_le32 (ts.tv_sec); - read->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&read->lat, sum); items++;/* encode the write latency metric */ @@ -75,9 +79,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->header.compat =1 ; write->header.data_len =cpu_to_le32 (sizeof (*write) - header_len); sum = m->metric[METRIC_WRITE ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - write->sec =cpu_to_le32 (ts.tv_sec); - write->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&write->lat, sum); items++;/* encode the metadata latency metric */ @@ -87,9 +89,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->header.compat =1 ; meta->header.data_len =cpu_to_le32 (sizeof (*meta) - header_len); sum = m->metric[METRIC_METADATA ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - meta->sec =cpu_to_le32 (ts.tv_sec); - meta->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&meta->lat, sum); items++;/* encode the dentry lease metric */ fs/ceph/metric.h +3
-5@@ -2,7 +2,7 @@#ifndef _FS_CEPH_MDS_METRIC_H#define _FS_CEPH_MDS_METRIC_H -#include <linux/types.h> +#include <linux/ceph/types.h> #include <linux/percpu_counter.h> #include <linux/ktime.h> @@ -60,22 +60,19 @@ struct ceph_metric_cap {/* metric read latency header */ struct ceph_metric_read_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric write latency header */ struct ceph_metric_write_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;
fs/ceph/metric.h struct ceph_metric_cap { · line 78
Quoted 10 lines
fs/ceph/metric.h +1
-2/* metric metadata latency header */ struct ceph_metric_metadata_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric dentry lease header */
Looks correct. Merged into testing branch. Thanks, Venky!
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 97 lines · Venky Shankar
Latencies are of type
ktime_t, coverting from jiffies is incorrect. Also, switch to "structceph_timespec" for r/w/m latencies.Signed-off-by Venky Shankar <[email protected]>--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)fs/ceph/metric.c +10
-10@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val) +{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec); +} +static bool ceph_mdsc_send_metrics (struct ceph_mds_client *mdsc,struct ceph_mds_session *s) {@@ -26,7 +33,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,u64 nr_caps =atomic64_read (&m->total_caps);u32 header_len =sizeof (struct ceph_metric_header );struct ceph_msg *msg; -struct timespec64 ts;s64 sum;s32 items =0 ;s32 len;@@ -63,9 +69,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->header.compat =1 ; read->header.data_len =cpu_to_le32 (sizeof (*read) - header_len); sum = m->metric[METRIC_READ ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - read->sec =cpu_to_le32 (ts.tv_sec); - read->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&read->lat, sum); items++;/* encode the write latency metric */ @@ -75,9 +79,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->header.compat =1 ; write->header.data_len =cpu_to_le32 (sizeof (*write) - header_len); sum = m->metric[METRIC_WRITE ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - write->sec =cpu_to_le32 (ts.tv_sec); - write->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&write->lat, sum); items++;/* encode the metadata latency metric */ @@ -87,9 +89,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->header.compat =1 ; meta->header.data_len =cpu_to_le32 (sizeof (*meta) - header_len); sum = m->metric[METRIC_METADATA ].latency_sum; -jiffies_to_timespec64 (sum, &ts); - meta->sec =cpu_to_le32 (ts.tv_sec); - meta->nsec =cpu_to_le32 (ts.tv_nsec); +to_ceph_timespec (&meta->lat, sum); items++;/* encode the dentry lease metric */ fs/ceph/metric.h +3
-5@@ -2,7 +2,7 @@#ifndef _FS_CEPH_MDS_METRIC_H#define _FS_CEPH_MDS_METRIC_H -#include <linux/types.h> +#include <linux/ceph/types.h> #include <linux/percpu_counter.h> #include <linux/ktime.h> @@ -60,22 +60,19 @@ struct ceph_metric_cap {/* metric read latency header */ struct ceph_metric_read_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric write latency header */ struct ceph_metric_write_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;
fs/ceph/metric.h struct ceph_metric_cap { · line 78
Quoted 10 lines
fs/ceph/metric.h +1
-2/* metric metadata latency header */ struct ceph_metric_metadata_latency {struct ceph_metric_header header; -__le32 sec; -__le32 nsec; +struct ceph_timespec lat; } __packed;/* metric dentry lease header */
LGTM.
Ilya Dryomov
maintainerQuoted 15 lines · Venky Shankar
Latencies are of type
ktime_t, coverting from jiffies is incorrect. Also, switch to "structceph_timespec" for r/w/m latencies.Signed-off-by Venky Shankar <[email protected]>--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)fs/ceph/metric.c +0
-0
fs/ceph/metric.c line 11
Quoted 4 lines
fs/ceph/metric.c +1
-0@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val)
Hi Venky,
I think ktime_to_ceph_timespec() would be a much better name.
fs/ceph/metric.c line 15
Quoted 4 lines
fs/ceph/metric.c +4
-0+{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec);
ceph_encode_timespec64() does this with appropriate casts, let's use it.
Thanks,
Ilya
Quoted 26 lines · Ilya Dryomov
Quoted 15 lines · Venky Shankar
Latencies are of type
ktime_t, coverting from jiffies is incorrect. Also, switch to "structceph_timespec" for r/w/m latencies.Signed-off-by Venky Shankar <[email protected]>--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)fs/ceph/metric.c +0
-0fs/ceph/metric.c line 11
Quoted 4 lines
fs/ceph/metric.c +1
-0@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val)Hi Venky,
I think
ktime_to_ceph_timespec()would be a much better name.
Quoted 7 lines
fs/ceph/metric.c line 15
Quoted 4 lines
fs/ceph/metric.c +4
-0+{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec);
ceph_encode_timespec64()does this with appropriate casts, let's use it.
Makes sense.
BTW, this fix would be a new change I guess? (rather than sending an updated version of the patch since it has been merged in -testing)?
Quoted 5 lines
Thanks,
Ilya
Signature · 2 lines
Cheers, Venky
Quoted 32 lines · Venky Shankar
Quoted 31 lines · Ilya Dryomov
Quoted 15 lines · Venky Shankar
Latencies are of type
ktime_t, coverting from jiffies is incorrect. Also, switch to "structceph_timespec" for r/w/m latencies.Signed-off-by Venky Shankar <[email protected]>--- fs/ceph/metric.c | 20 ++++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 14 insertions(+), 17 deletions(-)fs/ceph/metric.c +0
-0fs/ceph/metric.c line 11
Quoted 4 lines
fs/ceph/metric.c +1
-0@@ -8,6 +8,13 @@#include "metric.h" #include "mds_client.h" +static void to_ceph_timespec (struct ceph_timespec *ts,ktime_t val)Hi Venky,
I think
ktime_to_ceph_timespec()would be a much better name.Quoted 4 lines
fs/ceph/metric.c +4
-0+{ +struct timespec64 t =ktime_to_timespec64 (val); + ts->tv_sec =cpu_to_le32 (t.tv_sec); + ts->tv_nsec =cpu_to_le32 (t.tv_nsec);
Quoted 8 lines
Quoted 2 lines
ceph_encode_timespec64()does this with appropriate casts, let's use it.Makes sense.
BTW, this fix would be a new change I guess? (rather than sending an updated version of the patch since it has been merged in -testing)?
Better to send a v2 patch. We rebase "testing" all the time and that means less "churn" overall.
Signature · 1 line
Jeff Layton <[email protected]>