SUNRPC: Fix a backchannel deadlock
Subsystems (3)
PATCH v2 1/2 SUNRPC: Fix a backchannel deadlock
xprt_alloc_bc_request() cannot call xprt_free_bc_request() without deadlocking, since it already holds the xprt->bc_pa_lock.
Reported-by Chuck Lever <[email protected]>
Fixes 0d2a970d0ae55 ("SUNRPC: Fix a backchannel race")
Signed-off-by Trond Myklebust <[email protected]>
--- net/sunrpc/backchannel_rqst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/backchannel_rqst.c +2 -2
@@ -240,8 +240,8 @@ static struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt, __be32 xid) req =xprt_alloc_bc_req (xprt,GFP_ATOMIC );if (!req) goto not_found; -/* Note: this 'free' request adds it to xprt->bc_pa_list */ -xprt_free_bc_request (req); +list_add_tail (&req->rq_bc_pa_list, &xprt->bc_pa_list); + xprt->bc_alloc_count++; } req = list_first_entry(&xprt->bc_pa_list, struct rpc_rqst, rq_bc_pa_list);
Signature · 1 line
2.4.3
PATCH v2 2/2 SUNRPC: xprt_complete_bc_request must also decrement the free slot count
Calling xprt_complete_bc_request() effectively causes the slot to be allocated, so it needs to decrement the backchannel free slot count as well.
Fixes 0d2a970d0ae5 ("SUNRPC: Fix a backchannel race")
Signed-off-by Trond Myklebust <[email protected]>
--- net/sunrpc/backchannel_rqst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/backchannel_rqst.c +1 -1
@@ -336,7 +336,7 @@ void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied)spin_lock (&xprt->bc_pa_lock);list_del (&req->rq_bc_pa_list); - xprt->bc_alloc_count--; +xprt_dec_alloc_count (xprt,1 );spin_unlock (&xprt->bc_pa_lock); req->rq_private_buf.len = copied;
Signature · 1 line
2.4.3