@@ -147,6 +147,12 @@ static int metric_show(struct seq_file *s, void *p)
avg = jiffies_to_usecs(avg);
seq_printf(s, "%-14s%-12lld%lld\n", "write", total, avg);
+ total = percpu_counter_sum(&m->total_metadatas);
+ sum = percpu_counter_sum(&m->metadata_latency_sum);
+ avg = total ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
+ avg = jiffies_to_usecs(avg);
+ seq_printf(s, "%-14s%-12lld%lld\n", "metadata", total, avg);
+
seq_printf(s, "\n");
seq_printf(s, "item total miss hit\n");
seq_printf(s, "-------------------------------------------------\n");
@@ -2547,6 +2547,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
static void complete_request(struct ceph_mds_client *mdsc,
struct ceph_mds_request *req)
{
+ req->r_ended = jiffies;
+
if (req->r_callback)
req->r_callback(mdsc, req);
complete_all(&req->r_completion);
@@ -3155,6 +3157,9 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
/* kick calling process */
complete_request(mdsc, req);
+
+ ceph_update_metadata_latency(&mdsc->metric, req->r_started,
+ req->r_ended, err);
out:
ceph_mdsc_put_request(req);
return;
@@ -298,7 +298,8 @@ struct ceph_mds_request {
u32 r_readdir_offset;
unsigned long r_timeout; /* optional. jiffies, 0 is "wait forever" */
- unsigned long r_started; /* start time to measure timeout against */
+ unsigned long r_started; /* start time to measure timeout against and latency */
+ unsigned long r_ended; /* finish time to measure latency */
unsigned long r_request_started; /* start time for mds request only,
used to measure lease durations */
@@ -45,8 +45,20 @@ int ceph_metric_init(struct ceph_client_metric *m)
if (ret)
goto err_write_latency_sum;
+ ret = percpu_counter_init(&m->total_metadatas, 0, GFP_KERNEL);
+ if (ret)
+ goto err_total_metadatas;
+
+ ret = percpu_counter_init(&m->metadata_latency_sum, 0, GFP_KERNEL);
+ if (ret)
+ goto err_metadata_latency_sum;
+
return 0;
+err_metadata_latency_sum:
+ percpu_counter_destroy(&m->total_metadatas);
+err_total_metadatas:
+ percpu_counter_destroy(&m->write_latency_sum);
err_write_latency_sum:
percpu_counter_destroy(&m->total_writes);
err_total_writes:
@@ -70,6 +82,8 @@ void ceph_metric_destroy(struct ceph_client_metric *m)
if (!m)
return;
+ percpu_counter_destroy(&m->metadata_latency_sum);
+ percpu_counter_destroy(&m->total_metadatas);
percpu_counter_destroy(&m->write_latency_sum);
percpu_counter_destroy(&m->total_writes);
percpu_counter_destroy(&m->read_latency_sum);
@@ -19,6 +19,9 @@ struct ceph_client_metric {
struct percpu_counter total_writes;
struct percpu_counter write_latency_sum;
+
+ struct percpu_counter total_metadatas;
+ struct percpu_counter metadata_latency_sum;
};
extern int ceph_metric_init(struct ceph_client_metric *m);
@@ -57,4 +60,16 @@ static inline void ceph_update_write_latency(struct ceph_client_metric *m,
percpu_counter_inc(&m->total_writes);
percpu_counter_add(&m->write_latency_sum, r_end - r_start);
}
+
+static inline void ceph_update_metadata_latency(struct ceph_client_metric *m,
+ unsigned long r_start,
+ unsigned long r_end,
+ int rc)
+{
+ if (rc && rc != -ENOENT)
+ return;
+
+ percpu_counter_inc(&m->total_metadatas);
+ percpu_counter_add(&m->metadata_latency_sum, r_end - r_start);
+}
#endif /* _FS_CEPH_MDS_METRIC_H */