xprtrdma: RPC/RDMA must invoke xprt_wake_pending_tasks() in process context
authorChuck Lever <chuck.lever@oracle.com>
Wed, 28 May 2014 14:32:17 +0000 (10:32 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 4 Jun 2014 12:56:36 +0000 (08:56 -0400)
An IB provider can invoke rpcrdma_conn_func() in an IRQ context,
thus rpcrdma_conn_func() cannot be allowed to directly invoke
generic RPC functions like xprt_wake_pending_tasks().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/rpc_rdma.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index 400aa1b77d728cb56a6fc46afd61879380d94b6e..c296468a6f965101db7c6b202368d10ccbf3d9f2 100644 (file)
@@ -676,15 +676,11 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
        rqst->rq_private_buf = rqst->rq_rcv_buf;
 }
 
-/*
- * This function is called when an async event is posted to
- * the connection which changes the connection state. All it
- * does at this point is mark the connection up/down, the rpc
- * timers do the rest.
- */
 void
-rpcrdma_conn_func(struct rpcrdma_ep *ep)
+rpcrdma_connect_worker(struct work_struct *work)
 {
+       struct rpcrdma_ep *ep =
+               container_of(work, struct rpcrdma_ep, rep_connect_worker.work);
        struct rpc_xprt *xprt = ep->rep_xprt;
 
        spin_lock_bh(&xprt->transport_lock);
@@ -700,6 +696,18 @@ rpcrdma_conn_func(struct rpcrdma_ep *ep)
        spin_unlock_bh(&xprt->transport_lock);
 }
 
+/*
+ * This function is called when an async event is posted to
+ * the connection which changes the connection state. All it
+ * does at this point is mark the connection up/down, the rpc
+ * timers do the rest.
+ */
+void
+rpcrdma_conn_func(struct rpcrdma_ep *ep)
+{
+       schedule_delayed_work(&ep->rep_connect_worker, 0);
+}
+
 /*
  * This function is called when memory window unbind which we are waiting
  * for completes. Just use rr_func (zeroed by upcall) to signal completion.
index 8f9704e0f03de89f4e411d27becfa1b4be87a7e5..9cb88f373c7a669578366aa9deec6c51edea1f59 100644 (file)
@@ -742,6 +742,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
        INIT_CQCOUNT(ep);
        ep->rep_ia = ia;
        init_waitqueue_head(&ep->rep_connect_wait);
+       INIT_DELAYED_WORK(&ep->rep_connect_worker, rpcrdma_connect_worker);
 
        /*
         * Create a single cq for receive dto and mw_bind (only ever
@@ -817,6 +818,8 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
        dprintk("RPC:       %s: entering, connected is %d\n",
                __func__, ep->rep_connected);
 
+       cancel_delayed_work_sync(&ep->rep_connect_worker);
+
        if (ia->ri_id->qp) {
                rc = rpcrdma_ep_disconnect(ep, ia);
                if (rc)
index 98340a31f2bcb0e399a771026d6735db744d3995..c620d1332933327b2191bb145f27b46f184f1c7c 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/wait.h>                /* wait_queue_head_t, etc */
 #include <linux/spinlock.h>            /* spinlock_t, etc */
 #include <linux/atomic.h>                      /* atomic_t, etc */
+#include <linux/workqueue.h>           /* struct work_struct */
 
 #include <rdma/rdma_cm.h>              /* RDMA connection api */
 #include <rdma/ib_verbs.h>             /* RDMA verbs api */
@@ -87,6 +88,7 @@ struct rpcrdma_ep {
        struct rpc_xprt         *rep_xprt;      /* for rep_func */
        struct rdma_conn_param  rep_remote_cma;
        struct sockaddr_storage rep_remote_addr;
+       struct delayed_work     rep_connect_worker;
 };
 
 #define INIT_CQCOUNT(ep) atomic_set(&(ep)->rep_cqcount, (ep)->rep_cqinit)
@@ -336,6 +338,7 @@ int rpcrdma_deregister_external(struct rpcrdma_mr_seg *,
 /*
  * RPC/RDMA connection management calls - xprtrdma/rpc_rdma.c
  */
+void rpcrdma_connect_worker(struct work_struct *);
 void rpcrdma_conn_func(struct rpcrdma_ep *);
 void rpcrdma_reply_handler(struct rpcrdma_rep *);