Skip to content

Commit 14ed970

Browse files
John Sprayliewegas
authored andcommitted
ceph: additional debugfs output
MDS session state and client global ID is useful instrumentation when testing. Signed-off-by: John Spray <john.spray@redhat.com>
1 parent a687eca commit 14ed970

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎fs/ceph/debugfs.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,47 @@ static int dentry_lru_show(struct seq_file *s, void *ptr)
158158
return 0;
159159
}
160160

161+
static int mds_sessions_show(struct seq_file *s, void *ptr)
162+
{
163+
struct ceph_fs_client *fsc = s->private;
164+
struct ceph_mds_client *mdsc = fsc->mdsc;
165+
struct ceph_auth_client *ac = fsc->client->monc.auth;
166+
struct ceph_options *opt = fsc->client->options;
167+
int mds = -1;
168+
169+
mutex_lock(&mdsc->mutex);
170+
171+
/* The 'num' portion of an 'entity name' */
172+
seq_printf(s, "global_id %llu\n", ac->global_id);
173+
174+
/* The -o name mount argument */
175+
seq_printf(s, "name \"%s\"\n", opt->name ? opt->name : "");
176+
177+
/* The list of MDS session rank+state */
178+
for (mds = 0; mds < mdsc->max_sessions; mds++) {
179+
struct ceph_mds_session *session =
180+
__ceph_lookup_mds_session(mdsc, mds);
181+
if (!session) {
182+
continue;
183+
}
184+
mutex_unlock(&mdsc->mutex);
185+
seq_printf(s, "mds.%d %s\n",
186+
session->s_mds,
187+
ceph_session_state_name(session->s_state));
188+
189+
ceph_put_mds_session(session);
190+
mutex_lock(&mdsc->mutex);
191+
}
192+
mutex_unlock(&mdsc->mutex);
193+
194+
return 0;
195+
}
196+
161197
CEPH_DEFINE_SHOW_FUNC(mdsmap_show)
162198
CEPH_DEFINE_SHOW_FUNC(mdsc_show)
163199
CEPH_DEFINE_SHOW_FUNC(caps_show)
164200
CEPH_DEFINE_SHOW_FUNC(dentry_lru_show)
201+
CEPH_DEFINE_SHOW_FUNC(mds_sessions_show)
165202

166203

167204
/*
@@ -193,6 +230,7 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
193230
debugfs_remove(fsc->debugfs_bdi);
194231
debugfs_remove(fsc->debugfs_congestion_kb);
195232
debugfs_remove(fsc->debugfs_mdsmap);
233+
debugfs_remove(fsc->debugfs_mds_sessions);
196234
debugfs_remove(fsc->debugfs_caps);
197235
debugfs_remove(fsc->debugfs_mdsc);
198236
debugfs_remove(fsc->debugfs_dentry_lru);
@@ -231,6 +269,14 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
231269
if (!fsc->debugfs_mdsmap)
232270
goto out;
233271

272+
fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions",
273+
0600,
274+
fsc->client->debugfs_dir,
275+
fsc,
276+
&mds_sessions_show_fops);
277+
if (!fsc->debugfs_mds_sessions)
278+
goto out;
279+
234280
fsc->debugfs_mdsc = debugfs_create_file("mdsc",
235281
0600,
236282
fsc->client->debugfs_dir,

‎fs/ceph/super.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct ceph_fs_client {
9595
struct dentry *debugfs_congestion_kb;
9696
struct dentry *debugfs_bdi;
9797
struct dentry *debugfs_mdsc, *debugfs_mdsmap;
98+
struct dentry *debugfs_mds_sessions;
9899
#endif
99100

100101
#ifdef CONFIG_CEPH_FSCACHE

0 commit comments

Comments
 (0)