Skip to content

Commit ff4a80b

Browse files
jtlaytonidryomov
authored andcommitted
ceph: dump granular cap info in "caps" debugfs file
We have a "caps" file already that gives statistics on the caps cache as a whole. Add another section to that output and dump a line for each individual cap record. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent f5d7726 commit ff4a80b

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

‎fs/ceph/debugfs.c‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,48 @@ static int mdsc_show(struct seq_file *s, void *p)
124124
return 0;
125125
}
126126

127+
static int caps_show_cb(struct inode *inode, struct ceph_cap *cap, void *p)
128+
{
129+
struct seq_file *s = p;
130+
131+
seq_printf(s, "0x%-17lx%-17s%-17s\n", inode->i_ino,
132+
ceph_cap_string(cap->issued),
133+
ceph_cap_string(cap->implemented));
134+
return 0;
135+
}
136+
127137
static int caps_show(struct seq_file *s, void *p)
128138
{
129139
struct ceph_fs_client *fsc = s->private;
130-
int total, avail, used, reserved, min;
140+
struct ceph_mds_client *mdsc = fsc->mdsc;
141+
int total, avail, used, reserved, min, i;
131142

132143
ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
133144
seq_printf(s, "total\t\t%d\n"
134145
"avail\t\t%d\n"
135146
"used\t\t%d\n"
136147
"reserved\t%d\n"
137-
"min\t%d\n",
148+
"min\t\t%d\n\n",
138149
total, avail, used, reserved, min);
150+
seq_printf(s, "ino issued implemented\n");
151+
seq_printf(s, "-----------------------------------------------\n");
152+
153+
mutex_lock(&mdsc->mutex);
154+
for (i = 0; i < mdsc->max_sessions; i++) {
155+
struct ceph_mds_session *session;
156+
157+
session = __ceph_lookup_mds_session(mdsc, i);
158+
if (!session)
159+
continue;
160+
mutex_unlock(&mdsc->mutex);
161+
mutex_lock(&session->s_mutex);
162+
ceph_iterate_session_caps(session, caps_show_cb, s);
163+
mutex_unlock(&session->s_mutex);
164+
ceph_put_mds_session(session);
165+
mutex_lock(&mdsc->mutex);
166+
}
167+
mutex_unlock(&mdsc->mutex);
168+
139169
return 0;
140170
}
141171

0 commit comments

Comments
 (0)