ceph: add check_session_state() helper and make it global
And remove the unsed mdsc parameter to simplify the code. Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
@@ -1785,8 +1785,7 @@ static void renewed_caps(struct ceph_mds_client *mdsc,
|
|||||||
/*
|
/*
|
||||||
* send a session close request
|
* send a session close request
|
||||||
*/
|
*/
|
||||||
static int request_close_session(struct ceph_mds_client *mdsc,
|
static int request_close_session(struct ceph_mds_session *session)
|
||||||
struct ceph_mds_session *session)
|
|
||||||
{
|
{
|
||||||
struct ceph_msg *msg;
|
struct ceph_msg *msg;
|
||||||
|
|
||||||
@@ -1809,7 +1808,7 @@ static int __close_session(struct ceph_mds_client *mdsc,
|
|||||||
if (session->s_state >= CEPH_MDS_SESSION_CLOSING)
|
if (session->s_state >= CEPH_MDS_SESSION_CLOSING)
|
||||||
return 0;
|
return 0;
|
||||||
session->s_state = CEPH_MDS_SESSION_CLOSING;
|
session->s_state = CEPH_MDS_SESSION_CLOSING;
|
||||||
return request_close_session(mdsc, session);
|
return request_close_session(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool drop_negative_children(struct dentry *dentry)
|
static bool drop_negative_children(struct dentry *dentry)
|
||||||
@@ -4263,6 +4262,29 @@ static void maybe_recover_session(struct ceph_mds_client *mdsc)
|
|||||||
ceph_force_reconnect(fsc->sb);
|
ceph_force_reconnect(fsc->sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_session_state(struct ceph_mds_session *s)
|
||||||
|
{
|
||||||
|
if (s->s_state == CEPH_MDS_SESSION_CLOSING) {
|
||||||
|
dout("resending session close request for mds%d\n",
|
||||||
|
s->s_mds);
|
||||||
|
request_close_session(s);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
|
||||||
|
if (s->s_state == CEPH_MDS_SESSION_OPEN) {
|
||||||
|
s->s_state = CEPH_MDS_SESSION_HUNG;
|
||||||
|
pr_info("mds%d hung\n", s->s_mds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s->s_state == CEPH_MDS_SESSION_NEW ||
|
||||||
|
s->s_state == CEPH_MDS_SESSION_RESTARTING ||
|
||||||
|
s->s_state == CEPH_MDS_SESSION_REJECTED)
|
||||||
|
/* this mds is failed or recovering, just wait */
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* delayed work -- periodically trim expired leases, renew caps with mds
|
* delayed work -- periodically trim expired leases, renew caps with mds
|
||||||
*/
|
*/
|
||||||
@@ -4294,23 +4316,8 @@ static void delayed_work(struct work_struct *work)
|
|||||||
struct ceph_mds_session *s = __ceph_lookup_mds_session(mdsc, i);
|
struct ceph_mds_session *s = __ceph_lookup_mds_session(mdsc, i);
|
||||||
if (!s)
|
if (!s)
|
||||||
continue;
|
continue;
|
||||||
if (s->s_state == CEPH_MDS_SESSION_CLOSING) {
|
|
||||||
dout("resending session close request for mds%d\n",
|
if (!check_session_state(s)) {
|
||||||
s->s_mds);
|
|
||||||
request_close_session(mdsc, s);
|
|
||||||
ceph_put_mds_session(s);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
|
|
||||||
if (s->s_state == CEPH_MDS_SESSION_OPEN) {
|
|
||||||
s->s_state = CEPH_MDS_SESSION_HUNG;
|
|
||||||
pr_info("mds%d hung\n", s->s_mds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (s->s_state == CEPH_MDS_SESSION_NEW ||
|
|
||||||
s->s_state == CEPH_MDS_SESSION_RESTARTING ||
|
|
||||||
s->s_state == CEPH_MDS_SESSION_REJECTED) {
|
|
||||||
/* this mds is failed or recovering, just wait */
|
|
||||||
ceph_put_mds_session(s);
|
ceph_put_mds_session(s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <linux/ceph/auth.h>
|
#include <linux/ceph/auth.h>
|
||||||
|
|
||||||
#include "metric.h"
|
#include "metric.h"
|
||||||
|
#include "super.h"
|
||||||
|
|
||||||
/* The first 8 bits are reserved for old ceph releases */
|
/* The first 8 bits are reserved for old ceph releases */
|
||||||
enum ceph_feature_type {
|
enum ceph_feature_type {
|
||||||
@@ -476,6 +477,8 @@ struct ceph_mds_client {
|
|||||||
|
|
||||||
extern const char *ceph_mds_op_name(int op);
|
extern const char *ceph_mds_op_name(int op);
|
||||||
|
|
||||||
|
extern bool check_session_state(struct ceph_mds_session *s);
|
||||||
|
|
||||||
extern struct ceph_mds_session *
|
extern struct ceph_mds_session *
|
||||||
__ceph_lookup_mds_session(struct ceph_mds_client *, int mds);
|
__ceph_lookup_mds_session(struct ceph_mds_client *, int mds);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user