From: Xiubo Li <xiubli@xxxxxxxxxx>
The logic is the same with osdc/Objecter.cc in ceph in user space.
URL: https://tracker.ceph.com/issues/48053
Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx>
---
V2:
- remove other not used counter metrics
include/linux/ceph/osd_client.h | 9 ++++++
net/ceph/debugfs.c | 13 ++++++++
net/ceph/osd_client.c | 56 +++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 83fa08a06507..24301513b186 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -339,6 +339,13 @@ struct ceph_osd_backoff {
struct ceph_hobject_id *end;
};
+struct ceph_osd_metric {
+ struct percpu_counter op_ops;
+ struct percpu_counter op_rmw;
+ struct percpu_counter op_r;
+ struct percpu_counter op_w;
+};
+
#define CEPH_LINGER_ID_START 0xffff000000000000ULL
struct ceph_osd_client {
@@ -371,6 +378,8 @@ struct ceph_osd_client {
struct ceph_msgpool msgpool_op;
struct ceph_msgpool msgpool_op_reply;
+ struct ceph_osd_metric metric;
+
struct workqueue_struct *notify_wq;
struct workqueue_struct *completion_wq;
};
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index 2110439f8a24..af90019386ab 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -339,6 +339,16 @@ static void dump_backoffs(struct seq_file *s, struct ceph_osd *osd)
mutex_unlock(&osd->lock);
}
+static void dump_op_metric(struct seq_file *s, struct ceph_osd_client *osdc)
+{
+ struct ceph_osd_metric *m = &osdc->metric;
+
+ seq_printf(s, " op_ops: %lld\n", percpu_counter_sum(&m->op_ops));
+ seq_printf(s, " op_rmw: %lld\n", percpu_counter_sum(&m->op_rmw));
+ seq_printf(s, " op_r: %lld\n", percpu_counter_sum(&m->op_r));
+ seq_printf(s, " op_w: %lld\n", percpu_counter_sum(&m->op_w));
+}
+
static int osdc_show(struct seq_file *s, void *pp)
{
struct ceph_client *client = s->private;
@@ -372,6 +382,9 @@ static int osdc_show(struct seq_file *s, void *pp)
}
up_read(&osdc->lock);
+
+ seq_puts(s, "OP METRIC:\n");
+ dump_op_metric(s, osdc);
return 0;
}
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 7901ab6c79fd..66774b2bc584 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2424,6 +2424,21 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
goto again;
}
+static void osd_acount_op_metric(struct ceph_osd_request *req)
+{
+ struct ceph_osd_metric *m = &req->r_osdc->metric;
+
+ percpu_counter_inc(&m->op_ops);
+
+ if ((req->r_flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_READ))
+ == (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_READ))
+ percpu_counter_inc(&m->op_rmw);