]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
libceph: fix fault locking; close socket on lossy fault
authorSage Weil <sage@inktank.com>
Fri, 20 Jul 2012 22:22:53 +0000 (15:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 26 Nov 2012 19:38:40 +0000 (11:38 -0800)
(cherry picked from commit 3b5ede07b55b52c3be27749d183d87257d032065)

If we fault on a lossy connection, we should still close the socket
immediately, and do so under the con mutex.

We should also take the con mutex before printing out the state bits in
the debug output.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ceph/messenger.c

index 9da18929c588f6b82d08faaffa37f94aab8582f6..d769a73e080a289ff1f7e665abd216878593137a 100644 (file)
@@ -2330,22 +2330,23 @@ fault:
  */
 static void ceph_fault(struct ceph_connection *con)
 {
+       mutex_lock(&con->mutex);
+
        pr_err("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
               ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
        dout("fault %p state %lu to peer %s\n",
             con, con->state, ceph_pr_addr(&con->peer_addr.in_addr));
 
-       if (test_bit(LOSSYTX, &con->flags)) {
-               dout("fault on LOSSYTX channel\n");
-               goto out;
-       }
-
-       mutex_lock(&con->mutex);
        if (test_bit(CLOSED, &con->state))
                goto out_unlock;
 
        con_close_socket(con);
 
+       if (test_bit(LOSSYTX, &con->flags)) {
+               dout("fault on LOSSYTX channel\n");
+               goto out_unlock;
+       }
+
        if (con->in_msg) {
                BUG_ON(con->in_msg->con != con);
                con->in_msg->con = NULL;
@@ -2392,7 +2393,6 @@ static void ceph_fault(struct ceph_connection *con)
 
 out_unlock:
        mutex_unlock(&con->mutex);
-out:
        /*
         * in case we faulted due to authentication, invalidate our
         * current tickets so that we can get new ones.