ceph: periodically send perf metrics to ceph
Subsystems (2)
v2 cover ceph: periodically send perf metrics to ceph
From: Xiubo Li <[email protected]>
This series is based the previous patches of the metrics in kceph[1] and mds daemons record and forward client side metrics to manager[2][3].
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every metric_send_interval seconds, which is a module parameter, the valid values for metric_send_interval will be 0~5 seconds, 0 means disabled.
And will also send the metric flags to MDS, currently it supports the cap, read latency, write latency and metadata latency.
Also have pushed this series to github [4].
[1] https://patchwork.kernel.org/project/ceph-devel/list/?series=238907 [Merged]
[2] https://github.com/ceph/ceph/pull/26004 [Merged]
[3] https://github.com/ceph/ceph/pull/35608 [Merged]
[4] https://github.com/lxbsz/ceph-client/commits/perf_metric2
Changed in V2:
- split the patches into small ones as possible.
- check the METRIC_COLLECT feature before sending metrics
- switch to WARN_ON and bubble up errnos to the callers
Xiubo Li (5):
ceph: add check_session_state helper and make it global
ceph: periodically send perf metrics to ceph
ceph: check the METRIC_COLLECT feature before sending metrics
ceph: switch to WARN_ON and bubble up errnos to the callers
ceph: send client provided metric flags in client metadata
fs/ceph/mds_client.c | 147 ++++++++++++++++++++++++++++++++++--------- fs/ceph/mds_client.h | 8 ++- fs/ceph/metric.c | 142 +++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 91 +++++++++++++++++++++++++++ fs/ceph/super.c | 49 +++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 7 files changed, 410 insertions(+), 30 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/5 ceph: add check_session_state helper and make it global
From: Xiubo Li <[email protected]>
This will be used by followed sending metrics patches.
URL: https://tracker.ceph.com/issues/43215
--- fs/ceph/mds_client.c | 43 ++++++++++++++++++++++++++----------------- fs/ceph/mds_client.h | 4 ++++ 2 files changed, 30 insertions(+), 17 deletions(-)
fs/ceph/mds_client.c +26 -17
@@ -4263,6 +4263,30 @@ static void maybe_recover_session(struct ceph_mds_client *mdsc)ceph_force_reconnect (fsc->sb); } +bool check_session_state (struct ceph_mds_client *mdsc, +struct ceph_mds_session *s) +{ +if (s->s_state ==CEPH_MDS_SESSION_CLOSING ) { +dout ("resending session close request for mds%d\n" , + s->s_mds); +request_close_session (mdsc, s); +return false; + } +if (s->s_ttl &&time_after (jiffies, s->s_ttl)) { +if (s->s_state ==CEPH_MDS_SESSION_OPEN ) { + s->s_state =CEPH_MDS_SESSION_HUNG ; +pr_info ("mds%d hung\n" , s->s_mds); + } + } +if (s->s_state ==CEPH_MDS_SESSION_NEW || + s->s_state ==CEPH_MDS_SESSION_RESTARTING || + s->s_state ==CEPH_MDS_SESSION_REJECTED ) +/* this mds is failed or recovering, just wait */ +return false; + +return true; +} +/* * delayed work -- periodically trim expired leases, renew caps with mds */
@@ -4294,23 +4318,8 @@ static void delayed_work(struct work_struct *work)struct ceph_mds_session *s =__ceph_lookup_mds_session (mdsc, i);if (!s)continue ; -if (s->s_state ==CEPH_MDS_SESSION_CLOSING ) { -dout ("resending session close request for mds%d\n" , - s->s_mds); -request_close_session (mdsc, s); -ceph_put_mds_session (s); -continue ; - } -if (s->s_ttl &&time_after (jiffies, s->s_ttl)) { -if (s->s_state ==CEPH_MDS_SESSION_OPEN ) { - s->s_state =CEPH_MDS_SESSION_HUNG ; -pr_info ("mds%d hung\n" , s->s_mds); - } - } -if (s->s_state ==CEPH_MDS_SESSION_NEW || - s->s_state ==CEPH_MDS_SESSION_RESTARTING || - s->s_state ==CEPH_MDS_SESSION_REJECTED ) { -/* this mds is failed or recovering, just wait */ + +if (!check_session_state (mdsc, s)) {ceph_put_mds_session (s);continue ; }
fs/ceph/mds_client.h +4 -0
@@ -18,6 +18,7 @@#include <linux/ceph/auth.h> #include "metric.h" +#include "super.h" /* The first 8 bits are reserved for old ceph releases */ enum ceph_feature_type {
@@ -476,6 +477,9 @@ struct ceph_mds_client {extern const char *ceph_mds_op_name (int op); +extern bool check_session_state (struct ceph_mds_client *mdsc, +struct ceph_mds_session *s); +extern struct ceph_mds_session *__ceph_lookup_mds_session (struct ceph_mds_client *,int mds);
Signature · 1 line
1.8.3.1
PATCH v2 2/5 ceph: periodically send perf metrics to ceph
In reply to [email protected]From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every metric_send_interval seconds, which is a module parameter.
URL: https://tracker.ceph.com/issues/43215
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)
fs/ceph/mds_client.c +3 -0
@@ -4625,6 +4625,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc)cancel_work_sync (&mdsc->cap_reclaim_work);cancel_delayed_work_sync (&mdsc->delayed_work);/* cancel timer */ +cancel_delayed_work_sync (&mdsc->metric.delayed_work);/* cancel timer */ dout ("stopped\n" ); }
@@ -4667,6 +4668,7 @@ static void ceph_mdsc_stop(struct ceph_mds_client *mdsc) {dout ("stop\n" );cancel_delayed_work_sync (&mdsc->delayed_work);/* cancel timer */ +cancel_delayed_work_sync (&mdsc->metric.delayed_work);/* cancel timer */ if (mdsc->mdsmap)ceph_mdsmap_destroy (mdsc->mdsmap);kfree (mdsc->sessions);
@@ -4824,6 +4826,7 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)mutex_unlock (&mdsc->mutex);schedule_delayed (mdsc); +metric_schedule_delayed (&mdsc->metric);return ; bad_unlock:
fs/ceph/metric.c +134 -0
150 lines not on this page · raw message
fs/ceph/metric.h +78 -0
92 lines not on this page · raw message
fs/ceph/super.c +49 -0
73 lines not on this page · raw message
fs/ceph/super.h +2 -0
@@ -101,6 +101,8 @@ struct ceph_mount_options {struct ceph_fs_client {struct super_block *sb; +struct list_head list; +struct ceph_mount_options *mount_options;struct ceph_client *client;
include/linux/ceph/ceph_fs.h +1 -0
@@ -130,6 +130,7 @@ struct ceph_dir_layout {#define CEPH_MSG_CLIENT_REQUEST 24#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25#define CEPH_MSG_CLIENT_REPLY 26 +#define CEPH_MSG_CLIENT_METRICS 29#define CEPH_MSG_CLIENT_CAPS 0x310#define CEPH_MSG_CLIENT_LEASE 0x311#define CEPH_MSG_CLIENT_SNAP 0x312
Signature · 1 line
1.8.3.1
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>
Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)
I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 47 lines
fs/ceph/super.c +18
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval);
fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 10 lines
fs/ceph/super.c +10
-0+if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + } + +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +
Why do we want to reject an interval larger than 5s? Is that problematic for some reason? In any case, it would be good to replace this with a #defined constant that describes what that value represents.
Quoted 42 lines
fs/ceph/super.c +21
-0+ metric_send_interval = interval; + +// wake up all the mds clients +mutex_lock (&ceph_fsc_lock); +list_for_each_entry (fsc, &ceph_fsc_list, list) { +metric_schedule_delayed (&fsc->mdsc->metric); + } +mutex_unlock (&ceph_fsc_lock); + +return 0 ; +} + +static const struct kernel_param_ops param_ops_metric_interval = { + .set = param_set_metric_interval, + .get = param_get_uint, +}; + +unsigned int metric_send_interval =1 ; +module_param_cb (metric_send_interval, ¶m_ops_metric_interval, &metric_send_interval,0644 ); +MODULE_PARM_DESC (metric_send_interval,"Interval (in seconds) of sending perf metric to ceph cluster, valid values are 0~5, 0 means disabled (default: 1)" ); +module_init (init_ceph);module_exit (exit_ceph);fs/ceph/super.h +2
-0@@ -101,6 +101,8 @@ struct ceph_mount_options {struct ceph_fs_client {struct super_block *sb; +struct list_head list; +struct ceph_mount_options *mount_options;struct ceph_client *client;include/linux/ceph/ceph_fs.h +0
-0
include/linux/ceph/ceph_fs.h struct ceph_dir_layout { · line 136
Quoted 7 lines
include/linux/ceph/ceph_fs.h +1
-0@@ -130,6 +130,7 @@ struct ceph_dir_layout {#define CEPH_MSG_CLIENT_REQUEST 24#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25#define CEPH_MSG_CLIENT_REPLY 26 +#define CEPH_MSG_CLIENT_METRICS 29#define CEPH_MSG_CLIENT_CAPS 0x310#define CEPH_MSG_CLIENT_LEASE 0x311#define CEPH_MSG_CLIENT_SNAP 0x312
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 74 lines · Jeff Layton
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 51 lines
fs/ceph/super.c +22
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval); +if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + }
Quoted 8 lines
fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 6 lines
fs/ceph/super.c +6
-0+ +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +Why do we want to reject an interval larger than 5s? Is that problematic for some reason?
IMO, a larger interval doesn't make much sense, to limit the interval value in 5s to make sure that the ceph side could show the client real metrics in time. Is this okay ? Or should we use a larger limit ?
Quoted 2 lines
In any case, it would be good to replace this with a #defined constant that describes what that value represents.
Sure, I will add one macro in next version.
Thanks,
Quoted 50 lines
Quoted 42 lines
fs/ceph/super.c +21
-0+ metric_send_interval = interval; + +// wake up all the mds clients +mutex_lock (&ceph_fsc_lock); +list_for_each_entry (fsc, &ceph_fsc_list, list) { +metric_schedule_delayed (&fsc->mdsc->metric); + } +mutex_unlock (&ceph_fsc_lock); + +return 0 ; +} + +static const struct kernel_param_ops param_ops_metric_interval = { + .set = param_set_metric_interval, + .get = param_get_uint, +}; + +unsigned int metric_send_interval =1 ; +module_param_cb (metric_send_interval, ¶m_ops_metric_interval, &metric_send_interval,0644 ); +MODULE_PARM_DESC (metric_send_interval,"Interval (in seconds) of sending perf metric to ceph cluster, valid values are 0~5, 0 means disabled (default: 1)" ); +module_init (init_ceph);module_exit (exit_ceph);fs/ceph/super.h +2
-0@@ -101,6 +101,8 @@ struct ceph_mount_options {struct ceph_fs_client {struct super_block *sb; +struct list_head list; +struct ceph_mount_options *mount_options;struct ceph_client *client;include/linux/ceph/ceph_fs.h +0
-0include/linux/ceph/ceph_fs.h struct ceph_dir_layout { · line 136
Quoted 7 lines
include/linux/ceph/ceph_fs.h +1
-0@@ -130,6 +130,7 @@ struct ceph_dir_layout {#define CEPH_MSG_CLIENT_REQUEST 24#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25#define CEPH_MSG_CLIENT_REPLY 26 +#define CEPH_MSG_CLIENT_METRICS 29#define CEPH_MSG_CLIENT_CAPS 0x310#define CEPH_MSG_CLIENT_LEASE 0x311#define CEPH_MSG_CLIENT_SNAP 0x312Thanks,
Ilya Dryomov
maintainerQuoted 85 lines · Xiubo Li
Quoted 74 lines · Jeff Layton
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 51 lines
fs/ceph/super.c +22
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval); +if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + }Quoted 8 lines
fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 6 lines
fs/ceph/super.c +6
-0+ +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +Why do we want to reject an interval larger than 5s? Is that problematic for some reason?
Quoted 3 lines
IMO, a larger interval doesn't make much sense, to limit the interval value in 5s to make sure that the ceph side could show the client real metrics in time. Is this okay ? Or should we use a larger limit ?
I wonder if providing the option to tune the interval makes sense at all then. Since most clients will be sending their metrics every second, the MDS may eventually start relying on that in some way. Would a simple on/off switch, to be used if sending metrics causes unforeseen trouble, work?
Thanks,
Ilya
Quoted 85 lines · Ilya Dryomov
Quoted 84 lines · Xiubo Li
Quoted 82 lines · Jeff Layton
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 47 lines
fs/ceph/super.c +18
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval);fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 10 lines
fs/ceph/super.c +10
-0+if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + } + +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +Why do we want to reject an interval larger than 5s? Is that problematic for some reason?
Quoted 4 lines
Quoted 3 lines
IMO, a larger interval doesn't make much sense, to limit the interval value in 5s to make sure that the ceph side could show the client real metrics in time. Is this okay ? Or should we use a larger limit ?
5s may seem like a lot now, but in 5-10 years we might be wishing we had the ability to change this to something else (e.g.: maybe we find that stats every 5s cause undue load on the MDS, and need to increase it).
Quoted 6 lines
I wonder if providing the option to tune the interval makes sense at all then. Since most clients will be sending their metrics every second, the MDS may eventually start relying on that in some way. Would a simple on/off switch, to be used if sending metrics causes unforeseen trouble, work?
Yeah, I'm leery of grabbing values out of our nether regions like this, and it doesn't seem like making this that configurable has many benefits.
Perhaps the preferred interval should be something advertised by the MDS in some way? New field in the mdsmap, perhaps?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 98 lines · Jeff Layton
Quoted 84 lines · Ilya Dryomov
Quoted 83 lines · Xiubo Li
Quoted 82 lines · Jeff Layton
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 47 lines
fs/ceph/super.c +18
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval);fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 10 lines
fs/ceph/super.c +10
-0+if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + } + +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +Why do we want to reject an interval larger than 5s? Is that problematic for some reason?
Quoted 3 lines
Quoted 3 lines
IMO, a larger interval doesn't make much sense, to limit the interval value in 5s to make sure that the ceph side could show the client real metrics in time. Is this okay ? Or should we use a larger limit ?
5s may seem like a lot now, but in 5-10 years we might be wishing we had the ability to change this to something else (e.g.: maybe we find that stats every 5s cause undue load on the MDS, and need to increase it).
Quoted 6 lines
I wonder if providing the option to tune the interval makes sense at all then. Since most clients will be sending their metrics every second, the MDS may eventually start relying on that in some way. Would a simple on/off switch, to be used if sending metrics causes unforeseen trouble, work?
Quoted 3 lines
Yeah, I'm leery of grabbing values out of our nether regions like this, and it doesn't seem like making this that configurable has many benefits.
Let's use an on/off switch here.
Quoted 2 lines
Perhaps the preferred interval should be something advertised by the MDS in some way? New field in the mdsmap, perhaps?
For this maybe we could add one MDS or global option in ceph or one parameter in MDS perf query interface based PR[1] in future.
For now the on/off switch should be good and enough.
[1] https://github.com/ceph/ceph/pull/29951
Thanks
BRs
Quoted 84 lines · Ilya Dryomov
Quoted 83 lines · Xiubo Li
Quoted 82 lines · Jeff Layton
Quoted 9 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
This will send the caps/read/write/metadata metrics to any available MDS only once per second as default, which will be the same as the userland client, or every
metric_send_intervalseconds, which is a module parameter.URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>Quoted 10 lines
--- fs/ceph/mds_client.c | 3 + fs/ceph/metric.c | 134 +++++++++++++++++++++++++++++++++++++++++++ fs/ceph/metric.h | 78 +++++++++++++++++++++++++ fs/ceph/super.c | 49 ++++++++++++++++ fs/ceph/super.h | 2 + include/linux/ceph/ceph_fs.h | 1 + 6 files changed, 267 insertions(+)I think 3/5 needs to moved ahead of this one or folded into it, as we'll have a temporary regression otherwise.
Quoted 47 lines
fs/ceph/super.c +18
-0@@ -27,6 +27,9 @@#include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> +static DEFINE_MUTEX (ceph_fsc_lock); +static LIST_HEAD (ceph_fsc_list); +/* * Ceph superblock operations * @@ -691,6 +694,10 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,if (!fsc->wb_pagevec_pool) goto fail_cap_wq; +mutex_lock (&ceph_fsc_lock); +list_add_tail (&fsc->list, &ceph_fsc_list); +mutex_unlock (&ceph_fsc_lock); +return fsc; fail_cap_wq:@@ -717,6 +724,10 @@ static void destroy_fs_client(struct ceph_fs_client *fsc) {dout ("destroy_fs_client %p\n" , fsc); +mutex_lock (&ceph_fsc_lock); +list_del (&fsc->list); +mutex_unlock (&ceph_fsc_lock); +ceph_mdsc_destroy (fsc);destroy_workqueue (fsc->inode_wq);destroy_workqueue (fsc->cap_wq);@@ -1282,6 +1293,44 @@ static void __exit exit_ceph(void)destroy_caches (); } +static int param_set_metric_interval (const char *val,const struct kernel_param *kp) +{ +struct ceph_fs_client *fsc; +unsigned int interval; +int ret; + + ret =kstrtouint (val,0 , &interval);fs/ceph/super.c static void __exit exit_ceph(void) · line 1312
Quoted 10 lines
fs/ceph/super.c +10
-0+if (ret <0 ) { +pr_err ("Failed to parse metric interval '%s'\n" , val); +return ret; + } + +if (interval >5 ) { +pr_err ("Invalid metric interval %u\n" , interval); +return -EINVAL ; + } +Why do we want to reject an interval larger than 5s? Is that problematic for some reason?
Quoted 8 lines
Quoted 3 lines
IMO, a larger interval doesn't make much sense, to limit the interval value in 5s to make sure that the ceph side could show the client real metrics in time. Is this okay ? Or should we use a larger limit ?
I wonder if providing the option to tune the interval makes sense at all then. Since most clients will be sending their metrics every second, the MDS may eventually start relying on that in some way. Would a simple on/off switch, to be used if sending metrics causes unforeseen trouble, work?
Hi Ilya,
Yeah, this sounds sensible.
Thanks
BRs
Quoted 5 lines
Thanks,
Ilya
PATCH v2 3/5 ceph: check the METRIC_COLLECT feature before sending metrics
In reply to [email protected]From: Xiubo Li <[email protected]>
Skip the MDS sessions if they don't support the metric collection, or the MDSs will close the socket connections directly when it get an unknown type message.
URL: https://tracker.ceph.com/issues/43215
--- fs/ceph/mds_client.h | 4 +++- fs/ceph/metric.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
fs/ceph/mds_client.h +3 -1
@@ -28,8 +28,9 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED ,CEPHFS_FEATURE_MULTI_RECONNECT ,CEPHFS_FEATURE_DELEG_INO , +CEPHFS_FEATURE_METRIC_COLLECT , - CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_DELEG_INO, + CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT, };/*
@@ -43,6 +44,7 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED , \CEPHFS_FEATURE_MULTI_RECONNECT , \CEPHFS_FEATURE_DELEG_INO , \ +CEPHFS_FEATURE_METRIC_COLLECT , \ \ CEPHFS_FEATURE_MAX, \ }
fs/ceph/metric.c +8 -0
@@ -127,6 +127,14 @@ static void metric_delayed_work(struct work_struct *work)continue ; } +/* +* Skip it if MDS doesn't support the metric collection, +* or the MDS will close the session's socket connection +* directly when it get this message. +*/ +if (!test_bit (CEPHFS_FEATURE_METRIC_COLLECT , &s->s_features)) +continue ; +/* Only send the metric once in any available session */ ret =ceph_mdsc_send_metrics (mdsc, s, nr_caps);ceph_put_mds_session (s);
Signature · 1 line
1.8.3.1
Re: [PATCH v2 3/5] ceph: check the METRIC_COLLECT feature before sending metrics
Quoted 45 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
Skip the MDS sessions if they don't support the metric collection, or the MDSs will close the socket connections directly when it get an unknown type message.
URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/mds_client.h | 4 +++- fs/ceph/metric.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)fs/ceph/mds_client.h +3
-1@@ -28,8 +28,9 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED ,CEPHFS_FEATURE_MULTI_RECONNECT ,CEPHFS_FEATURE_DELEG_INO , +CEPHFS_FEATURE_METRIC_COLLECT , - CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_DELEG_INO, + CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT, };/* @@ -43,6 +44,7 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED , \CEPHFS_FEATURE_MULTI_RECONNECT , \CEPHFS_FEATURE_DELEG_INO , \ +CEPHFS_FEATURE_METRIC_COLLECT , \ \ CEPHFS_FEATURE_MAX, \ }fs/ceph/metric.c +1
-0@@ -127,6 +127,14 @@ static void metric_delayed_work(struct work_struct *work)continue ; } +/*
fs/ceph/metric.c static void metric_delayed_work(struct work_struct *work) · line 140
Quoted 10 lines
fs/ceph/metric.c +7
-0+* Skip it if MDS doesn't support the metric collection, +* or the MDS will close the session's socket connection +* directly when it get this message. +*/ +if (!test_bit (CEPHFS_FEATURE_METRIC_COLLECT , &s->s_features)) +continue ; +/* Only send the metric once in any available session */ ret =ceph_mdsc_send_metrics (mdsc, s, nr_caps);ceph_put_mds_session (s);
This should probably be moved ahead of, or folded into the previous patch to prevent a regression should someone land in between them when bisecting.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v2 3/5] ceph: check the METRIC_COLLECT feature before sending metrics
Quoted 45 lines · Jeff Layton
Quoted 44 lines · On Thu, 2020-06-18 at 07:59 -0400, [email protected] wrote:
From: Xiubo Li <[email protected]>
Skip the MDS sessions if they don't support the metric collection, or the MDSs will close the socket connections directly when it get an unknown type message.
URL: https://tracker.ceph.com/issues/43215
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/mds_client.h | 4 +++- fs/ceph/metric.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)fs/ceph/mds_client.h +3
-1@@ -28,8 +28,9 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED ,CEPHFS_FEATURE_MULTI_RECONNECT ,CEPHFS_FEATURE_DELEG_INO , +CEPHFS_FEATURE_METRIC_COLLECT , - CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_DELEG_INO, + CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT, };/* @@ -43,6 +44,7 @@ enum ceph_feature_type {CEPHFS_FEATURE_LAZY_CAP_WANTED , \CEPHFS_FEATURE_MULTI_RECONNECT , \CEPHFS_FEATURE_DELEG_INO , \ +CEPHFS_FEATURE_METRIC_COLLECT , \ \ CEPHFS_FEATURE_MAX, \ }fs/ceph/metric.c +0
-0@@ -127,6 +127,14 @@ static void metric_delayed_work(struct work_struct *work)continue ; }
Quoted 14 lines
fs/ceph/metric.c static void metric_delayed_work(struct work_struct *work) · line 140
Quoted 11 lines
fs/ceph/metric.c +8
-0+/* +* Skip it if MDS doesn't support the metric collection, +* or the MDS will close the session's socket connection +* directly when it get this message. +*/ +if (!test_bit (CEPHFS_FEATURE_METRIC_COLLECT , &s->s_features)) +continue ; +/* Only send the metric once in any available session */ ret =ceph_mdsc_send_metrics (mdsc, s, nr_caps);ceph_put_mds_session (s);This should probably be moved ahead of, or folded into the previous patch to prevent a regression should someone land in between them when bisecting.
Yeah, make sense, let's fold it into the previous one.
Thanks.
PATCH v2 4/5 ceph: switch to WARN_ON and bubble up errnos to the callers
In reply to [email protected]From: Xiubo Li <[email protected]>
--- fs/ceph/mds_client.c | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-)
fs/ceph/mds_client.c +35 -11
@@ -1168,7 +1168,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)static const unsigned char feature_bits[] =CEPHFS_FEATURES_CLIENT_SUPPORTED ;#define FEATURE_BYTES (c) (DIV_ROUND_UP((size_t)feature_bits[c - 1] + 1, 64) * 8) -static void encode_supported_features (void **p,void *end) +static int encode_supported_features (void **p,void *end) {static const size_t count =ARRAY_SIZE (feature_bits);
@@ -1176,16 +1176,22 @@ static void encode_supported_features(void **p, void *end)size_t i;size_t size =FEATURE_BYTES (count); -BUG_ON (*p +4 + size > end); +if (WARN_ON (*p +4 + size > end)) +return -ERANGE ; +ceph_encode_32 (p, size);memset (*p,0 , size);for (i =0 ; i < count; i++) ((unsigned char *)(*p))[i /8 ] |=BIT (feature_bits[i] %8 ); *p += size; }else { -BUG_ON (*p +4 > end); +if (WARN_ON (*p +4 > end)) +return -ERANGE ; +ceph_encode_32 (p,0 ); } + +return 0 ; }/*
@@ -1203,6 +1209,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6struct ceph_mount_options *fsopt = mdsc->fsc->mount_options;size_t size, count;void *p, *end; +int ret;const char * metadata[][2 ] = { {"hostname" , mdsc->nodename},
@@ -1232,7 +1239,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 GFP_NOFS, false);if (!msg) {pr_err ("create_session_msg ENOMEM creating msg\n" ); -return NULL ; +return ERR_PTR (-ENOMEM ); } p = msg->front.iov_base; end = p + msg->front.iov_len;
@@ -1269,7 +1276,13 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 p += val_len; } -encode_supported_features (&p, end); + ret =encode_supported_features (&p, end); +if (ret) { +pr_err ("encode_supported_features failed!\n" ); +ceph_msg_put (msg); +return ERR_PTR (ret); + } + msg->front.iov_len = p - msg->front.iov_base; msg->hdr.front_len =cpu_to_le32 (msg->front.iov_len);
@@ -1297,8 +1310,8 @@ static int __open_session(struct ceph_mds_client *mdsc,/* send connect message */ msg =create_session_open_msg (mdsc, session->s_seq); -if (!msg) -return -ENOMEM ; +if (IS_ERR (msg)) +return PTR_ERR (msg);ceph_con_send (&session->s_con, msg);return 0 ; }
@@ -1312,6 +1325,7 @@ static int __open_session(struct ceph_mds_client *mdsc, __open_export_target_session(struct ceph_mds_client *mdsc, int target) {struct ceph_mds_session *session; +int ret; session =__ceph_lookup_mds_session (mdsc, target);if (!session) {
@@ -1320,8 +1334,11 @@ static int __open_session(struct ceph_mds_client *mdsc,return session; }if (session->s_state ==CEPH_MDS_SESSION_NEW || - session->s_state ==CEPH_MDS_SESSION_CLOSING ) -__open_session (mdsc, session); + session->s_state ==CEPH_MDS_SESSION_CLOSING ) { + ret =__open_session (mdsc, session); +if (ret) +return ERR_PTR (ret); + }return session; }
@@ -2520,7 +2537,12 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,ceph_encode_copy (&p, &ts,sizeof (ts)); } -BUG_ON (p > end); +if (WARN_ON (p > end)) { +ceph_msg_put (msg); + msg =ERR_PTR (-ERANGE ); + goto out_free2; + } + msg->front.iov_len = p - msg->front.iov_base; msg->hdr.front_len =cpu_to_le32 (msg->front.iov_len);
@@ -2756,7 +2778,9 @@ static void __do_request(struct ceph_mds_client *mdsc, }if (session->s_state ==CEPH_MDS_SESSION_NEW || session->s_state ==CEPH_MDS_SESSION_CLOSING ) { -__open_session (mdsc, session); + err =__open_session (mdsc, session); +if (err) + goto out_session;/* retry the same mds later */ if (random) req->r_resend_mds = mds;
Signature · 1 line
1.8.3.1
PATCH v2 5/5 ceph: send client provided metric flags in client metadata
In reply to [email protected]From: Xiubo Li <[email protected]>
Will send the metric flags to MDS, currently it supports the cap, read latency, write latency and metadata latency.
URL: https://tracker.ceph.com/issues/43435
--- fs/ceph/mds_client.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-- fs/ceph/metric.h | 13 ++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-)
fs/ceph/mds_client.c +58 -2
@@ -1194,6 +1194,48 @@ static int encode_supported_features(void **p, void *end)return 0 ; } +static const unsigned char metric_bits[] =CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED ; +#define METRIC_BYTES (cnt) (DIV_ROUND_UP((size_t)metric_bits[cnt - 1] + 1, 64) * 8) +static int encode_metric_spec (void **p,void *end) +{ +static const size_t count =ARRAY_SIZE (metric_bits); + +/* header */ +if (WARN_ON (*p +2 > end)) +return -ERANGE ; + +ceph_encode_8 (p,1 );/* version */ +ceph_encode_8 (p,1 );/* compat */ + +if (count >0 ) { +size_t i; +size_t size =METRIC_BYTES (count); + +if (WARN_ON (*p +4 +4 + size > end)) +return -ERANGE ; + +/* metric spec info length */ +ceph_encode_32 (p,4 + size); + +/* metric spec */ +ceph_encode_32 (p, size); +memset (*p,0 , size); +for (i =0 ; i < count; i++) + ((unsigned char *)(*p))[i /8 ] |=BIT (metric_bits[i] %8 ); + *p += size; + }else { +if (WARN_ON (*p +4 +4 > end)) +return -ERANGE ; + +/* metric spec info length */ +ceph_encode_32 (p,4 ); +/* metric spec */ +ceph_encode_32 (p,0 ); + } + +return 0 ; +} +/* * session message, specialization for CEPH_SESSION_REQUEST_OPEN * to include additional client metadata fields.
@@ -1234,6 +1276,13 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 size =FEATURE_BYTES (count); extra_bytes +=4 + size; +/* metric spec */ + size =0 ; + count =ARRAY_SIZE (metric_bits); +if (count >0 ) + size =METRIC_BYTES (count); + extra_bytes +=2 +4 +4 + size; +/* Allocate the message */ msg =ceph_msg_new (CEPH_MSG_CLIENT_SESSION ,sizeof (*h) + extra_bytes,GFP_NOFS , false);
@@ -1252,9 +1301,9 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6* Serialize client metadata into waiting buffer space, using * the format that userspace expects for map<string, string> * -* ClientSession messages with metadata are v3 +* ClientSession messages with metadata are v4 */ - msg->hdr.version =cpu_to_le16 (3 ); + msg->hdr.version =cpu_to_le16 (4 ); msg->hdr.compat_version =cpu_to_le16 (1 );/* The write pointer, following the session_head structure */
@@ -1283,6 +1332,13 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6return ERR_PTR (ret); } + ret =encode_metric_spec (&p, end); +if (ret) { +pr_err ("encode_metric_spec failed!\n" ); +ceph_msg_put (msg); +return ERR_PTR (ret); + } + msg->front.iov_len = p - msg->front.iov_base; msg->hdr.front_len =cpu_to_le32 (msg->front.iov_len);
fs/ceph/metric.h +13 -0
@@ -18,6 +18,19 @@ enum ceph_metric_type { CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_DENTRY_LEASE, }; +/* +* This will always have the highest metric bit value +* as the last element of the array. +*/ +#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED { \ + CLIENT_METRIC_TYPE_CAP_INFO, \ + CLIENT_METRIC_TYPE_READ_LATENCY, \ + CLIENT_METRIC_TYPE_WRITE_LATENCY, \ + CLIENT_METRIC_TYPE_METADATA_LATENCY, \ + \ + CLIENT_METRIC_TYPE_MAX, \ +} +/* metric caps header */ struct ceph_metric_cap {__le32 type;/* ceph metric type */
Signature · 1 line
1.8.3.1