summaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorSage Weil2012-07-21 00:34:04 +0200
committerSage Weil2012-07-31 03:15:57 +0200
commita59b55a602b6c741052d79c1e3643f8440cddd27 (patch)
tree4ffe59cd04d00fe0835256065b5b08a7c5505d1b /net/ceph
parentlibceph: move msgr clear_standby under con mutex protection (diff)
downloadkernel-qcow2-linux-a59b55a602b6c741052d79c1e3643f8440cddd27.tar.gz
kernel-qcow2-linux-a59b55a602b6c741052d79c1e3643f8440cddd27.tar.xz
kernel-qcow2-linux-a59b55a602b6c741052d79c1e3643f8440cddd27.zip
libceph: move ceph_con_send() closed check under the con mutex
Take the con mutex before checking whether the connection is closed to avoid racing with someone else closing it. Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 1a3cb4a4f180..20e60a80bc29 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2453,22 +2453,20 @@ static void clear_standby(struct ceph_connection *con)
*/
void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
{
- if (test_bit(CLOSED, &con->state)) {
- dout("con_send %p closed, dropping %p\n", con, msg);
- ceph_msg_put(msg);
- return;
- }
-
/* set src+dst */
msg->hdr.src = con->msgr->inst.name;
-
BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len));
-
msg->needs_out_seq = true;
- /* queue */
mutex_lock(&con->mutex);
+ if (test_bit(CLOSED, &con->state)) {
+ dout("con_send %p closed, dropping %p\n", con, msg);
+ ceph_msg_put(msg);
+ mutex_unlock(&con->mutex);
+ return;
+ }
+
BUG_ON(msg->con != NULL);
msg->con = con->ops->get(con);
BUG_ON(msg->con == NULL);