提交 42ce56e5 编写于 作者: S Sage Weil

ceph: remove bad calls to ceph_con_shutdown

We want to ceph_con_close when we're done with the connection, before
the ref count reaches 0.  Once it does, do not call ceph_con_shutdown,
as that takes the con mutex and may sleep, and besides that is
unnecessary.
Signed-off-by: NSage Weil <sage@newdream.net>
上级 11ea8eda
...@@ -274,10 +274,8 @@ void ceph_put_mds_session(struct ceph_mds_session *s) ...@@ -274,10 +274,8 @@ void ceph_put_mds_session(struct ceph_mds_session *s)
{ {
dout("mdsc put_session %p %d -> %d\n", s, dout("mdsc put_session %p %d -> %d\n", s,
atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
if (atomic_dec_and_test(&s->s_ref)) { if (atomic_dec_and_test(&s->s_ref))
ceph_con_shutdown(&s->s_con);
kfree(s); kfree(s);
}
} }
/* /*
...@@ -326,7 +324,6 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, ...@@ -326,7 +324,6 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
s->s_con.ops = &mds_con_ops; s->s_con.ops = &mds_con_ops;
s->s_con.peer_name.type = CEPH_ENTITY_TYPE_MDS; s->s_con.peer_name.type = CEPH_ENTITY_TYPE_MDS;
s->s_con.peer_name.num = cpu_to_le64(mds); s->s_con.peer_name.num = cpu_to_le64(mds);
ceph_con_open(&s->s_con, ceph_mdsmap_get_addr(mdsc->mdsmap, mds));
spin_lock_init(&s->s_cap_lock); spin_lock_init(&s->s_cap_lock);
s->s_cap_gen = 0; s->s_cap_gen = 0;
...@@ -352,7 +349,7 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, ...@@ -352,7 +349,7 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
dout("register_session realloc to %d\n", newmax); dout("register_session realloc to %d\n", newmax);
sa = kcalloc(newmax, sizeof(void *), GFP_NOFS); sa = kcalloc(newmax, sizeof(void *), GFP_NOFS);
if (sa == NULL) if (sa == NULL)
return ERR_PTR(-ENOMEM); goto fail_realloc;
if (mdsc->sessions) { if (mdsc->sessions) {
memcpy(sa, mdsc->sessions, memcpy(sa, mdsc->sessions,
mdsc->max_sessions * sizeof(void *)); mdsc->max_sessions * sizeof(void *));
...@@ -363,17 +360,26 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, ...@@ -363,17 +360,26 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
} }
mdsc->sessions[mds] = s; mdsc->sessions[mds] = s;
atomic_inc(&s->s_ref); /* one ref to sessions[], one to caller */ atomic_inc(&s->s_ref); /* one ref to sessions[], one to caller */
ceph_con_open(&s->s_con, ceph_mdsmap_get_addr(mdsc->mdsmap, mds));
return s; return s;
fail_realloc:
kfree(s);
return ERR_PTR(-ENOMEM);
} }
/* /*
* called under mdsc->mutex * called under mdsc->mutex
*/ */
static void unregister_session(struct ceph_mds_client *mdsc, int mds) static void unregister_session(struct ceph_mds_client *mdsc,
struct ceph_mds_session *s)
{ {
dout("unregister_session mds%d %p\n", mds, mdsc->sessions[mds]); dout("unregister_session mds%d %p\n", s->s_mds, s);
ceph_put_mds_session(mdsc->sessions[mds]); mdsc->sessions[s->s_mds] = NULL;
mdsc->sessions[mds] = NULL; ceph_con_close(&s->s_con);
ceph_put_mds_session(s);
} }
/* /*
...@@ -1870,7 +1876,7 @@ static void handle_session(struct ceph_mds_session *session, ...@@ -1870,7 +1876,7 @@ static void handle_session(struct ceph_mds_session *session,
break; break;
case CEPH_SESSION_CLOSE: case CEPH_SESSION_CLOSE:
unregister_session(mdsc, mds); unregister_session(mdsc, session);
remove_session_caps(session); remove_session_caps(session);
wake = 1; /* for good measure */ wake = 1; /* for good measure */
complete(&mdsc->session_close_waiters); complete(&mdsc->session_close_waiters);
...@@ -2199,7 +2205,7 @@ static void check_new_map(struct ceph_mds_client *mdsc, ...@@ -2199,7 +2205,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
/* the session never opened, just close it /* the session never opened, just close it
* out now */ * out now */
__wake_requests(mdsc, &s->s_waiting); __wake_requests(mdsc, &s->s_waiting);
unregister_session(mdsc, i); unregister_session(mdsc, s);
} else { } else {
/* just close it */ /* just close it */
mutex_unlock(&mdsc->mutex); mutex_unlock(&mdsc->mutex);
...@@ -2724,7 +2730,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc) ...@@ -2724,7 +2730,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc)
for (i = 0; i < mdsc->max_sessions; i++) { for (i = 0; i < mdsc->max_sessions; i++) {
if (mdsc->sessions[i]) { if (mdsc->sessions[i]) {
session = get_session(mdsc->sessions[i]); session = get_session(mdsc->sessions[i]);
unregister_session(mdsc, i); unregister_session(mdsc, session);
mutex_unlock(&mdsc->mutex); mutex_unlock(&mdsc->mutex);
mutex_lock(&session->s_mutex); mutex_lock(&session->s_mutex);
remove_session_caps(session); remove_session_caps(session);
......
...@@ -212,7 +212,6 @@ extern void ceph_messenger_destroy(struct ceph_messenger *); ...@@ -212,7 +212,6 @@ extern void ceph_messenger_destroy(struct ceph_messenger *);
extern void ceph_con_init(struct ceph_messenger *msgr, extern void ceph_con_init(struct ceph_messenger *msgr,
struct ceph_connection *con); struct ceph_connection *con);
extern void ceph_con_shutdown(struct ceph_connection *con);
extern void ceph_con_open(struct ceph_connection *con, extern void ceph_con_open(struct ceph_connection *con,
struct ceph_entity_addr *addr); struct ceph_entity_addr *addr);
extern void ceph_con_close(struct ceph_connection *con); extern void ceph_con_close(struct ceph_connection *con);
......
...@@ -350,10 +350,8 @@ static void put_osd(struct ceph_osd *osd) ...@@ -350,10 +350,8 @@ static void put_osd(struct ceph_osd *osd)
{ {
dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
atomic_read(&osd->o_ref) - 1); atomic_read(&osd->o_ref) - 1);
if (atomic_dec_and_test(&osd->o_ref)) { if (atomic_dec_and_test(&osd->o_ref))
ceph_con_shutdown(&osd->o_con);
kfree(osd); kfree(osd);
}
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册