[pnfs] [PATCH 1/1] nfs41: Use bottom half spinlock in callback list processing

Benny Halevy bhalevy at panasas.com
Thu Mar 6 14:32:17 EST 2008


Merged onto the nfs41 branch

Benny

On Mar. 05, 2008, 2:02 +0200, Ricardo Labiaga <ricardo.labiaga at netapp.com> wrote:
> From: Ricardo Labiaga <Ricardo.Labiaga at netapp.com>
> 
> Switch from reader/writers lock to spinlock for manipulation of the
> backchannel preallocated lists.  Only the exclusive access writers lock
> was being used so there's no need for readers/writers functionality.
> 
> Use bottom half spinlocks as well. Other spinlocks in xprt.c and xprtsock.c
> during transport I/O are already bottom half.
> 
> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga at netapp.com>
> ---
>  include/linux/sunrpc/xprt.h   |    2 +-
>  net/sunrpc/backchannel_rqst.c |   16 ++++++++--------
>  net/sunrpc/xprt.c             |    2 +-
>  3 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
> index 763daf6..55b617d 100644
> --- a/include/linux/sunrpc/xprt.h
> +++ b/include/linux/sunrpc/xprt.h
> @@ -180,7 +180,7 @@ struct rpc_xprt {
>  	struct svc_serv		*serv;		/* The RPC service which will */
>  						/* process the callback */
>  	unsigned int		bc_alloc_count;	/* Total number of preallocs */
> -	rwlock_t		bc_pa_lock;	/* Protects the preallocated */
> +	spinlock_t		bc_pa_lock;	/* Protects the preallocated */
>  						/* items */
>  	struct list_head	bc_pa_list;	/* List of preallocated */
>  						/* backchannel rpc_rqst's */
> diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
> index 09f90f9..660a666 100644
> --- a/net/sunrpc/backchannel_rqst.c
> +++ b/net/sunrpc/backchannel_rqst.c
> @@ -146,10 +146,10 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
>  	/*
>  	 * Add the temporary list to the backchannel preallocation list
>  	 */
> -	write_lock(&xprt->bc_pa_lock);
> +	spin_lock_bh(&xprt->bc_pa_lock);
>  	list_splice(&tmp_list, &xprt->bc_pa_list);
>  	xprt_inc_alloc_count(xprt, min_reqs);
> -	write_unlock(&xprt->bc_pa_lock);
> +	spin_unlock_bh(&xprt->bc_pa_lock);
>  
>  	dprintk("RPC:       setup backchannel transport done\n");
>  	return 0;
> @@ -182,7 +182,7 @@ void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
>  	dprintk("RPC:        destroy backchannel transport\n");
>  
>  	BUG_ON(max_reqs == 0);
> -	write_lock(&xprt->bc_pa_lock);
> +	spin_lock_bh(&xprt->bc_pa_lock);
>  	xprt_dec_alloc_count(xprt, max_reqs);
>  	list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list,
>  					  rq_bc_pa_list) {
> @@ -191,7 +191,7 @@ void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
>  		if (--max_reqs == 0)
>  			break;
>  	}
> -	write_unlock(&xprt->bc_pa_lock);
> +	spin_unlock_bh(&xprt->bc_pa_lock);
>  
>  	dprintk("RPC:        backchannel list empty= %s\n",
>  		list_empty(&xprt->bc_pa_list) ? "true" : "false");
> @@ -211,7 +211,7 @@ struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt)
>  	struct rpc_rqst *req;
>  
>  	dprintk("RPC:       allocate a backchannel request\n");
> -	write_lock(&xprt->bc_pa_lock);
> +	spin_lock_bh(&xprt->bc_pa_lock);
>  	if (!list_empty(&xprt->bc_pa_list)) {
>  		req = list_first_entry(&xprt->bc_pa_list, struct rpc_rqst,
>  				rq_bc_pa_list);
> @@ -219,7 +219,7 @@ struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt)
>  	} else {
>  		req = NULL;
>  	}
> -	write_unlock(&xprt->bc_pa_lock);
> +	spin_unlock_bh(&xprt->bc_pa_lock);
>  
>  	if (req != NULL) {
>  		set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
> @@ -261,9 +261,9 @@ void xprt_free_bc_request(struct rpc_rqst *req)
>  	 * Return it to the list of preallocations so that it
>  	 * may be reused by a new callback request.
>  	 */
> -	write_lock(&xprt->bc_pa_lock);
> +	spin_lock_bh(&xprt->bc_pa_lock);
>  	list_add(&req->rq_bc_pa_list, &xprt->bc_pa_list);
> -	write_unlock(&xprt->bc_pa_lock);
> +	spin_unlock_bh(&xprt->bc_pa_lock);
>  }
>  EXPORT_SYMBOL(xprt_free_bc_request);
>  
> diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> index 416ce42..44c2d23 100644
> --- a/net/sunrpc/xprt.c
> +++ b/net/sunrpc/xprt.c
> @@ -1052,7 +1052,7 @@ found:
>  	kref_init(&xprt->kref);
>  	spin_lock_init(&xprt->transport_lock);
>  	spin_lock_init(&xprt->reserve_lock);
> -	rwlock_init(&xprt->bc_pa_lock);
> +	spin_lock_init(&xprt->bc_pa_lock);
>  
>  	INIT_LIST_HEAD(&xprt->free);
>  	INIT_LIST_HEAD(&xprt->recv);



More information about the pNFS mailing list