Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions fs/ceph/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,49 @@ static int dentry_lru_show(struct seq_file *s, void *ptr)
return 0;
}

static int mds_sessions_show(struct seq_file *s, void *ptr)
{
struct ceph_fs_client *fsc = s->private;
struct ceph_mds_client *mdsc = fsc->mdsc;
struct ceph_auth_client *ac = fsc->client->monc.auth;
struct ceph_options *opt = fsc->client->options;
int mds = -1;

mutex_lock(&mdsc->mutex);

// The 'num' portion of an 'entity name'
seq_printf(s, "global_id %llu\n", ac->global_id);

// The -o name mount argument
seq_printf(s, "name \"%s\"\n", opt->name ? opt->name : "");

// The list of MDS session rank+state

for (mds = 0; mds < mdsc->max_sessions; mds++) {
struct ceph_mds_session *session = __ceph_lookup_mds_session(mdsc, mds);
if (!session) {
continue;
}

mutex_unlock(&mdsc->mutex);

seq_printf(s, "mds.%d %s\n",
session->s_mds,
ceph_session_state_name(session->s_state));

ceph_put_mds_session(session);
mutex_lock(&mdsc->mutex);
}
mutex_unlock(&mdsc->mutex);

return 0;
}

CEPH_DEFINE_SHOW_FUNC(mdsmap_show)
CEPH_DEFINE_SHOW_FUNC(mdsc_show)
CEPH_DEFINE_SHOW_FUNC(caps_show)
CEPH_DEFINE_SHOW_FUNC(dentry_lru_show)
CEPH_DEFINE_SHOW_FUNC(mds_sessions_show)


/*
Expand Down Expand Up @@ -193,6 +232,7 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
debugfs_remove(fsc->debugfs_bdi);
debugfs_remove(fsc->debugfs_congestion_kb);
debugfs_remove(fsc->debugfs_mdsmap);
debugfs_remove(fsc->debugfs_mds_sessions);
debugfs_remove(fsc->debugfs_caps);
debugfs_remove(fsc->debugfs_mdsc);
debugfs_remove(fsc->debugfs_dentry_lru);
Expand Down Expand Up @@ -231,6 +271,14 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
if (!fsc->debugfs_mdsmap)
goto out;

fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions",
0600,
fsc->client->debugfs_dir,
fsc,
&mds_sessions_show_fops);
if (!fsc->debugfs_mds_sessions)
goto out;

fsc->debugfs_mdsc = debugfs_create_file("mdsc",
0600,
fsc->client->debugfs_dir,
Expand Down
14 changes: 7 additions & 7 deletions fs/ceph/mds_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static void destroy_reply_info(struct ceph_mds_reply_info_parsed *info)
/*
* sessions
*/
static const char *session_state_name(int s)
const char *ceph_session_state_name(int s)
{
switch (s) {
case CEPH_MDS_SESSION_NEW: return "new";
Expand Down Expand Up @@ -1232,7 +1232,7 @@ static int send_flushmsg_ack(struct ceph_mds_client *mdsc,
struct ceph_msg *msg;

dout("send_flushmsg_ack to mds%d (%s)s seq %lld\n",
session->s_mds, session_state_name(session->s_state), seq);
session->s_mds, ceph_session_state_name(session->s_state), seq);
msg = create_session_msg(CEPH_SESSION_FLUSHMSG_ACK, seq);
if (!msg)
return -ENOMEM;
Expand Down Expand Up @@ -1284,7 +1284,7 @@ static int request_close_session(struct ceph_mds_client *mdsc,
struct ceph_msg *msg;

dout("request_close_session mds%d state %s seq %lld\n",
session->s_mds, session_state_name(session->s_state),
session->s_mds, ceph_session_state_name(session->s_state),
session->s_seq);
msg = create_session_msg(CEPH_SESSION_REQUEST_CLOSE, session->s_seq);
if (!msg)
Expand Down Expand Up @@ -2077,7 +2077,7 @@ static int __do_request(struct ceph_mds_client *mdsc,
req->r_session = get_session(session);

dout("do_request mds%d session %p state %s\n", mds, session,
session_state_name(session->s_state));
ceph_session_state_name(session->s_state));
if (session->s_state != CEPH_MDS_SESSION_OPEN &&
session->s_state != CEPH_MDS_SESSION_HUNG) {
if (session->s_state == CEPH_MDS_SESSION_NEW ||
Expand Down Expand Up @@ -2515,7 +2515,7 @@ static void handle_session(struct ceph_mds_session *session,

dout("handle_session mds%d %s %p state %s seq %llu\n",
mds, ceph_session_op_name(op), session,
session_state_name(session->s_state), seq);
ceph_session_state_name(session->s_state), seq);

if (session->s_state == CEPH_MDS_SESSION_HUNG) {
session->s_state = CEPH_MDS_SESSION_OPEN;
Expand Down Expand Up @@ -2768,7 +2768,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
session->s_seq = 0;

dout("session %p state %s\n", session,
session_state_name(session->s_state));
ceph_session_state_name(session->s_state));

spin_lock(&session->s_gen_ttl_lock);
session->s_cap_gen++;
Expand Down Expand Up @@ -2901,7 +2901,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
ceph_mdsmap_is_laggy(oldmap, i) ? " (laggy)" : "",
ceph_mds_state_name(newstate),
ceph_mdsmap_is_laggy(newmap, i) ? " (laggy)" : "",
session_state_name(s->s_state));
ceph_session_state_name(s->s_state));

if (i >= newmap->m_max_mds ||
memcmp(ceph_mdsmap_get_addr(oldmap, i),
Expand Down
2 changes: 2 additions & 0 deletions fs/ceph/mds_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ ceph_get_mds_session(struct ceph_mds_session *s)
return s;
}

extern const char *ceph_session_state_name(int s);

extern void ceph_put_mds_session(struct ceph_mds_session *s);

extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
Expand Down
1 change: 1 addition & 0 deletions fs/ceph/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct ceph_fs_client {
struct dentry *debugfs_congestion_kb;
struct dentry *debugfs_bdi;
struct dentry *debugfs_mdsc, *debugfs_mdsmap;
struct dentry *debugfs_mds_sessions;
#endif

#ifdef CONFIG_CEPH_FSCACHE
Expand Down