@@ -146,6 +146,12 @@ static int metric_show(struct seq_file *s, void *p)
seq_printf(s, "%-14s%-12lld%-16lld%lld\n", "write",
total, sum / NSEC_PER_USEC, avg / NSEC_PER_USEC);
+ total = percpu_counter_sum(&mdsc->metric.total_metadatas);
+ sum = percpu_counter_sum(&mdsc->metric.metadata_latency_sum);
+ avg = total ? sum / total : 0;
+ seq_printf(s, "%-14s%-12lld%-16lld%lld\n", "metadata",
+ total, sum / NSEC_PER_USEC, avg / NSEC_PER_USEC);
+
seq_printf(s, "\n");
seq_printf(s, "item total miss hit\n");
seq_printf(s, "-------------------------------------------------\n");
@@ -2772,6 +2772,12 @@ static int ceph_mdsc_wait_request(struct ceph_mds_client *mdsc,
else
err = timeleft; /* killed */
}
+
+ if (!err || err == -EIO) {
+ s64 latency = jiffies - req->r_started;
+ ceph_update_metadata_latency(&mdsc->metric, latency);
+ }
+
dout("do_request waited, got %d\n", err);
mutex_lock(&mdsc->mutex);
@@ -3033,6 +3039,11 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
/* kick calling process */
complete_request(mdsc, req);
+
+ if (!result || result == -ENOENT) {
+ s64 latency = jiffies - req->r_started;
+ ceph_update_metadata_latency(&mdsc->metric, latency);
+ }
out:
ceph_mdsc_put_request(req);
return;
@@ -4203,7 +4214,19 @@ static int ceph_mdsc_metric_init(struct ceph_client_metric *metric)
if (ret)
goto err_write_latency_sum;
+ ret = percpu_counter_init(&metric->total_metadatas, 0, GFP_KERNEL);
+ if (ret)
+ goto err_total_metadatas;
+
+ ret = percpu_counter_init(&metric->metadata_latency_sum, 0, GFP_KERNEL);
+ if (ret)
+ goto err_metadata_latency_sum;
+
return ret;
+err_metadata_latency_sum:
+ percpu_counter_destroy(&metric->total_metadatas);
+err_total_metadatas:
+ percpu_counter_destroy(&metric->write_latency_sum);
err_write_latency_sum:
percpu_counter_destroy(&metric->total_writes);
err_total_writes:
@@ -4555,6 +4578,8 @@ void ceph_mdsc_destroy(struct ceph_fs_client *fsc)
ceph_mdsc_stop(mdsc);
+ percpu_counter_destroy(&mdsc->metric.metadata_latency_sum);
+ percpu_counter_destroy(&mdsc->metric.total_metadatas);
percpu_counter_destroy(&mdsc->metric.write_latency_sum);
percpu_counter_destroy(&mdsc->metric.total_writes);
percpu_counter_destroy(&mdsc->metric.read_latency_sum);
@@ -15,6 +15,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;
};
static inline void ceph_update_read_latency(struct ceph_client_metric *m,
@@ -44,4 +47,14 @@ static inline void ceph_update_write_latency(struct ceph_client_metric *m,
percpu_counter_add(&m->write_latency_sum, latency);
}
}
+
+static inline void ceph_update_metadata_latency(struct ceph_client_metric *m,
+ s64 latency)
+{
+ if (!m)
+ return;
+
+ percpu_counter_inc(&m->total_metadatas);
+ percpu_counter_add(&m->metadata_latency_sum, latency);
+}
#endif