* [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
@ 2022-02-09 15:38 Venky Shankar
2022-02-09 15:53 ` Jeff Layton
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Venky Shankar @ 2022-02-09 15:38 UTC (permalink / raw)
To: jlayton, xiubli; +Cc: ceph-devel, Venky Shankar
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>
---
fs/ceph/metric.c | 20 ++++++++++----------
fs/ceph/metric.h | 11 ++++-------
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
index 0fcba68f9a99..a9cd23561a0d 100644
--- a/fs/ceph/metric.c
+++ b/fs/ceph/metric.c
@@ -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 */
diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h
index bb45608181e7..5b2bb2897056 100644
--- a/fs/ceph/metric.h
+++ b/fs/ceph/metric.h
@@ -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 */
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
2022-02-09 15:38 [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64() Venky Shankar
@ 2022-02-09 15:53 ` Jeff Layton
2022-02-10 2:29 ` Xiubo Li
2022-03-01 17:02 ` Ilya Dryomov
2 siblings, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2022-02-09 15:53 UTC (permalink / raw)
To: Venky Shankar, xiubli; +Cc: ceph-devel
On Wed, 2022-02-09 at 21:08 +0530, Venky Shankar wrote:
> 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>
> ---
> fs/ceph/metric.c | 20 ++++++++++----------
> fs/ceph/metric.h | 11 ++++-------
> 2 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
> index 0fcba68f9a99..a9cd23561a0d 100644
> --- a/fs/ceph/metric.c
> +++ b/fs/ceph/metric.c
> @@ -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 */
> diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h
> index bb45608181e7..5b2bb2897056 100644
> --- a/fs/ceph/metric.h
> +++ b/fs/ceph/metric.h
> @@ -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 */
Looks correct. Merged into testing branch. Thanks, Venky!
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
2022-02-09 15:38 [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64() Venky Shankar
2022-02-09 15:53 ` Jeff Layton
@ 2022-02-10 2:29 ` Xiubo Li
2022-03-01 17:02 ` Ilya Dryomov
2 siblings, 0 replies; 6+ messages in thread
From: Xiubo Li @ 2022-02-10 2:29 UTC (permalink / raw)
To: Venky Shankar, jlayton; +Cc: ceph-devel
On 2/9/22 11:38 PM, Venky Shankar wrote:
> 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>
> ---
> fs/ceph/metric.c | 20 ++++++++++----------
> fs/ceph/metric.h | 11 ++++-------
> 2 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
> index 0fcba68f9a99..a9cd23561a0d 100644
> --- a/fs/ceph/metric.c
> +++ b/fs/ceph/metric.c
> @@ -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 */
> diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h
> index bb45608181e7..5b2bb2897056 100644
> --- a/fs/ceph/metric.h
> +++ b/fs/ceph/metric.h
> @@ -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 */
LGTM.
Reviewed-by: Xiubo Li <xiubli@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
2022-02-09 15:38 [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64() Venky Shankar
2022-02-09 15:53 ` Jeff Layton
2022-02-10 2:29 ` Xiubo Li
@ 2022-03-01 17:02 ` Ilya Dryomov
2022-03-04 13:20 ` Venky Shankar
2 siblings, 1 reply; 6+ messages in thread
From: Ilya Dryomov @ 2022-03-01 17:02 UTC (permalink / raw)
To: Venky Shankar; +Cc: Jeff Layton, Xiubo Li, Ceph Development
On Wed, Feb 9, 2022 at 7:55 PM Venky Shankar <vshankar@redhat.com> wrote:
>
> 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>
> ---
> fs/ceph/metric.c | 20 ++++++++++----------
> fs/ceph/metric.h | 11 ++++-------
> 2 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
> index 0fcba68f9a99..a9cd23561a0d 100644
> --- a/fs/ceph/metric.c
> +++ b/fs/ceph/metric.c
> @@ -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.
> +{
> + 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
2022-03-01 17:02 ` Ilya Dryomov
@ 2022-03-04 13:20 ` Venky Shankar
2022-03-04 13:33 ` Jeff Layton
0 siblings, 1 reply; 6+ messages in thread
From: Venky Shankar @ 2022-03-04 13:20 UTC (permalink / raw)
To: Ilya Dryomov; +Cc: Jeff Layton, Xiubo Li, Ceph Development
On Tue, Mar 1, 2022 at 10:32 PM Ilya Dryomov <idryomov@gmail.com> wrote:
>
> On Wed, Feb 9, 2022 at 7:55 PM Venky Shankar <vshankar@redhat.com> wrote:
> >
> > 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>
> > ---
> > fs/ceph/metric.c | 20 ++++++++++----------
> > fs/ceph/metric.h | 11 ++++-------
> > 2 files changed, 14 insertions(+), 17 deletions(-)
> >
> > diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
> > index 0fcba68f9a99..a9cd23561a0d 100644
> > --- a/fs/ceph/metric.c
> > +++ b/fs/ceph/metric.c
> > @@ -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.
>
> > +{
> > + 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)?
>
> Thanks,
>
> Ilya
>
--
Cheers,
Venky
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64()
2022-03-04 13:20 ` Venky Shankar
@ 2022-03-04 13:33 ` Jeff Layton
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2022-03-04 13:33 UTC (permalink / raw)
To: Venky Shankar, Ilya Dryomov; +Cc: Xiubo Li, Ceph Development
On Fri, 2022-03-04 at 18:50 +0530, Venky Shankar wrote:
> On Tue, Mar 1, 2022 at 10:32 PM Ilya Dryomov <idryomov@gmail.com> wrote:
> >
> > On Wed, Feb 9, 2022 at 7:55 PM Venky Shankar <vshankar@redhat.com> wrote:
> > >
> > > 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>
> > > ---
> > > fs/ceph/metric.c | 20 ++++++++++----------
> > > fs/ceph/metric.h | 11 ++++-------
> > > 2 files changed, 14 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
> > > index 0fcba68f9a99..a9cd23561a0d 100644
> > > --- a/fs/ceph/metric.c
> > > +++ b/fs/ceph/metric.c
> > > @@ -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.
> >
> > > +{
> > > + 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)?
>
Better to send a v2 patch. We rebase "testing" all the time and that
means less "churn" overall.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-04 13:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 15:38 [PATCH] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64() Venky Shankar
2022-02-09 15:53 ` Jeff Layton
2022-02-10 2:29 ` Xiubo Li
2022-03-01 17:02 ` Ilya Dryomov
2022-03-04 13:20 ` Venky Shankar
2022-03-04 13:33 ` Jeff Layton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.