Commit 4f1d756d authored by Xiubo Li's avatar Xiubo Li Committed by Ilya Dryomov

ceph: add global total_caps to count the mdsc's total caps number

This will help to reduce using the global mdsc->mutex lock in many
places.
Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 3e699bd8
...@@ -668,6 +668,7 @@ void ceph_add_cap(struct inode *inode, ...@@ -668,6 +668,7 @@ void ceph_add_cap(struct inode *inode,
spin_lock(&session->s_cap_lock); spin_lock(&session->s_cap_lock);
list_add_tail(&cap->session_caps, &session->s_caps); list_add_tail(&cap->session_caps, &session->s_caps);
session->s_nr_caps++; session->s_nr_caps++;
atomic64_inc(&mdsc->metric.total_caps);
spin_unlock(&session->s_cap_lock); spin_unlock(&session->s_cap_lock);
} else { } else {
spin_lock(&session->s_cap_lock); spin_lock(&session->s_cap_lock);
...@@ -1161,6 +1162,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) ...@@ -1161,6 +1162,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
} else { } else {
list_del_init(&cap->session_caps); list_del_init(&cap->session_caps);
session->s_nr_caps--; session->s_nr_caps--;
atomic64_dec(&mdsc->metric.total_caps);
cap->session = NULL; cap->session = NULL;
removed = 1; removed = 1;
} }
......
...@@ -145,7 +145,7 @@ static int metric_show(struct seq_file *s, void *p) ...@@ -145,7 +145,7 @@ static int metric_show(struct seq_file *s, void *p)
struct ceph_fs_client *fsc = s->private; struct ceph_fs_client *fsc = s->private;
struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_client *mdsc = fsc->mdsc;
struct ceph_client_metric *m = &mdsc->metric; struct ceph_client_metric *m = &mdsc->metric;
int i, nr_caps = 0; int nr_caps = 0;
s64 total, sum, avg, min, max, sq; s64 total, sum, avg, min, max, sq;
seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n"); seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n");
...@@ -190,17 +190,7 @@ static int metric_show(struct seq_file *s, void *p) ...@@ -190,17 +190,7 @@ static int metric_show(struct seq_file *s, void *p)
percpu_counter_sum(&m->d_lease_mis), percpu_counter_sum(&m->d_lease_mis),
percpu_counter_sum(&m->d_lease_hit)); percpu_counter_sum(&m->d_lease_hit));
mutex_lock(&mdsc->mutex); nr_caps = atomic64_read(&m->total_caps);
for (i = 0; i < mdsc->max_sessions; i++) {
struct ceph_mds_session *s;
s = __ceph_lookup_mds_session(mdsc, i);
if (!s)
continue;
nr_caps += s->s_nr_caps;
ceph_put_mds_session(s);
}
mutex_unlock(&mdsc->mutex);
seq_printf(s, "%-14s%-16d%-16lld%lld\n", "caps", nr_caps, seq_printf(s, "%-14s%-16d%-16lld%lld\n", "caps", nr_caps,
percpu_counter_sum(&m->i_caps_mis), percpu_counter_sum(&m->i_caps_mis),
percpu_counter_sum(&m->i_caps_hit)); percpu_counter_sum(&m->i_caps_hit));
......
...@@ -1485,6 +1485,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session, ...@@ -1485,6 +1485,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session,
cap->session = NULL; cap->session = NULL;
list_del_init(&cap->session_caps); list_del_init(&cap->session_caps);
session->s_nr_caps--; session->s_nr_caps--;
atomic64_dec(&session->s_mdsc->metric.total_caps);
if (cap->queue_release) if (cap->queue_release)
__ceph_queue_cap_release(session, cap); __ceph_queue_cap_release(session, cap);
else else
......
...@@ -22,6 +22,7 @@ int ceph_metric_init(struct ceph_client_metric *m) ...@@ -22,6 +22,7 @@ int ceph_metric_init(struct ceph_client_metric *m)
if (ret) if (ret)
goto err_d_lease_mis; goto err_d_lease_mis;
atomic64_set(&m->total_caps, 0);
ret = percpu_counter_init(&m->i_caps_hit, 0, GFP_KERNEL); ret = percpu_counter_init(&m->i_caps_hit, 0, GFP_KERNEL);
if (ret) if (ret)
goto err_i_caps_hit; goto err_i_caps_hit;
......
...@@ -12,6 +12,7 @@ struct ceph_client_metric { ...@@ -12,6 +12,7 @@ struct ceph_client_metric {
struct percpu_counter d_lease_hit; struct percpu_counter d_lease_hit;
struct percpu_counter d_lease_mis; struct percpu_counter d_lease_mis;
atomic64_t total_caps;
struct percpu_counter i_caps_hit; struct percpu_counter i_caps_hit;
struct percpu_counter i_caps_mis; struct percpu_counter i_caps_mis;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment