SUNRPC: Get rid of the redundant xprt->shutdown bit field
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 11 Sep 2012 21:21:25 +0000 (17:21 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 28 Sep 2012 20:03:05 +0000 (16:03 -0400)
It is only set after everyone has dereferenced the transport,
and serves no useful purpose: setting it is racy, so all the
socket code, etc still needs to be able to cope with the cases
where they miss reading it.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
include/linux/sunrpc/xprt.h
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtsock.c

index bf8c49ff7530c7ee8b85d4a8b3ccef5de86ff308..951cb9b7d02b9167982135a6245972c18605f1a0 100644 (file)
@@ -173,8 +173,7 @@ struct rpc_xprt {
        unsigned int            min_reqs;       /* min number of slots */
        atomic_t                num_reqs;       /* total slots */
        unsigned long           state;          /* transport state */
-       unsigned char           shutdown   : 1, /* being shut down */
-                               resvport   : 1; /* use a reserved port */
+       unsigned char           resvport   : 1; /* use a reserved port */
        unsigned int            swapper;        /* we're swapping over this
                                                   transport */
        unsigned int            bind_index;     /* bind function index */
index 5d7f61d7559c9753c9bff0f29b371b5e62b5f0d9..bd462a532acfa695906887db429896ae569eac26 100644 (file)
@@ -231,7 +231,7 @@ EXPORT_SYMBOL_GPL(xprt_reserve_xprt);
 static void xprt_clear_locked(struct rpc_xprt *xprt)
 {
        xprt->snd_task = NULL;
-       if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state) || xprt->shutdown) {
+       if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state)) {
                smp_mb__before_clear_bit();
                clear_bit(XPRT_LOCKED, &xprt->state);
                smp_mb__after_clear_bit();
@@ -504,9 +504,6 @@ EXPORT_SYMBOL_GPL(xprt_wait_for_buffer_space);
  */
 void xprt_write_space(struct rpc_xprt *xprt)
 {
-       if (unlikely(xprt->shutdown))
-               return;
-
        spin_lock_bh(&xprt->transport_lock);
        if (xprt->snd_task) {
                dprintk("RPC:       write space: waking waiting task on "
@@ -679,7 +676,7 @@ xprt_init_autodisconnect(unsigned long data)
        struct rpc_xprt *xprt = (struct rpc_xprt *)data;
 
        spin_lock(&xprt->transport_lock);
-       if (!list_empty(&xprt->recv) || xprt->shutdown)
+       if (!list_empty(&xprt->recv))
                goto out_abort;
        if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
                goto out_abort;
@@ -1262,7 +1259,6 @@ out:
 static void xprt_destroy(struct rpc_xprt *xprt)
 {
        dprintk("RPC:       destroying transport %p\n", xprt);
-       xprt->shutdown = 1;
        del_timer_sync(&xprt->timer);
 
        rpc_destroy_wait_queue(&xprt->binding);
index 5d9202dc7cb127f5158a2a6e275fa0656c18f0a6..c9aa7a35f3bf8332952573d0d04c22423980c7c2 100644 (file)
@@ -199,21 +199,15 @@ xprt_rdma_connect_worker(struct work_struct *work)
        struct rpc_xprt *xprt = &r_xprt->xprt;
        int rc = 0;
 
-       if (!xprt->shutdown) {
-               current->flags |= PF_FSTRANS;
-               xprt_clear_connected(xprt);
-
-               dprintk("RPC:       %s: %sconnect\n", __func__,
-                               r_xprt->rx_ep.rep_connected != 0 ? "re" : "");
-               rc = rpcrdma_ep_connect(&r_xprt->rx_ep, &r_xprt->rx_ia);
-               if (rc)
-                       goto out;
-       }
-       goto out_clear;
+       current->flags |= PF_FSTRANS;
+       xprt_clear_connected(xprt);
+
+       dprintk("RPC:       %s: %sconnect\n", __func__,
+                       r_xprt->rx_ep.rep_connected != 0 ? "re" : "");
+       rc = rpcrdma_ep_connect(&r_xprt->rx_ep, &r_xprt->rx_ia);
+       if (rc)
+               xprt_wake_pending_tasks(xprt, rc);
 
-out:
-       xprt_wake_pending_tasks(xprt, rc);
-out_clear:
        dprintk("RPC:       %s: exit\n", __func__);
        xprt_clear_connecting(xprt);
        current->flags &= ~PF_FSTRANS;
index 97f8918169edb423e7e2c8487e13758cee97c905..aaaadfbe36e9525a42a86e1f649bf66e59eb7274 100644 (file)
@@ -917,9 +917,6 @@ static void xs_local_data_ready(struct sock *sk, int len)
        if (skb == NULL)
                goto out;
 
-       if (xprt->shutdown)
-               goto dropit;
-
        repsize = skb->len - sizeof(rpc_fraghdr);
        if (repsize < 4) {
                dprintk("RPC:       impossible RPC reply size %d\n", repsize);
@@ -981,9 +978,6 @@ static void xs_udp_data_ready(struct sock *sk, int len)
        if ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL)
                goto out;
 
-       if (xprt->shutdown)
-               goto dropit;
-
        repsize = skb->len - sizeof(struct udphdr);
        if (repsize < 4) {
                dprintk("RPC:       impossible RPC reply size %d!\n", repsize);
@@ -1412,9 +1406,6 @@ static void xs_tcp_data_ready(struct sock *sk, int bytes)
        read_lock_bh(&sk->sk_callback_lock);
        if (!(xprt = xprt_from_sock(sk)))
                goto out;
-       if (xprt->shutdown)
-               goto out;
-
        /* Any data means we had a useful conversation, so
         * the we don't need to delay the next reconnect
         */
@@ -1901,9 +1892,6 @@ static void xs_local_setup_socket(struct work_struct *work)
        struct socket *sock;
        int status = -EIO;
 
-       if (xprt->shutdown)
-               goto out;
-
        current->flags |= PF_FSTRANS;
 
        clear_bit(XPRT_CONNECTION_ABORT, &xprt->state);
@@ -2020,9 +2008,6 @@ static void xs_udp_setup_socket(struct work_struct *work)
        struct socket *sock = transport->sock;
        int status = -EIO;
 
-       if (xprt->shutdown)
-               goto out;
-
        current->flags |= PF_FSTRANS;
 
        /* Start by resetting any existing state */
@@ -2168,9 +2153,6 @@ static void xs_tcp_setup_socket(struct work_struct *work)
        struct rpc_xprt *xprt = &transport->xprt;
        int status = -EIO;
 
-       if (xprt->shutdown)
-               goto out;
-
        current->flags |= PF_FSTRANS;
 
        if (!sock) {