@@ -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+
161197CEPH_DEFINE_SHOW_FUNC (mdsmap_show )
162198CEPH_DEFINE_SHOW_FUNC (mdsc_show )
163199CEPH_DEFINE_SHOW_FUNC (caps_show )
164200CEPH_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 ,
0 commit comments