All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 07/11] SUNRPC: Use a cached RPC client and transport for rpcbind upcalls
Date: Fri, 20 Nov 2009 15:18:05 -0500	[thread overview]
Message-ID: <1258748285.2494.84.camel@localhost> (raw)
In-Reply-To: <20091105182319.2796.62305.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>

On Thu, 2009-11-05 at 13:23 -0500, Chuck Lever wrote: 
> The kernel's rpcbind client creates and deletes an rpc_clnt and its
> underlying transport socket for every upcall to the local rpcbind
> daemon.
> 
> When starting a typical NFS server on IPv4 and IPv6, the NFS service
> itself does three upcalls (one per version) times two upcalls (one
> per transport) times two upcalls (one per address family), making 12,
> plus another one for the initial call to unregister previous NFS
> services.  Starting the NLM service adds an additional 13 upcalls,
> for similar reasons.
> 
> (Currently the NFS service doesn't start IPv6 listeners, but it will
> soon enough).
> 
> Instead, let's create an rpc_clnt for rpcbind upcalls during the
> first local rpcbind query, and cache it.  This saves the overhead of
> creating and destroying an rpc_clnt and a socket for every upcall.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> 
>  net/sunrpc/rpcb_clnt.c   |   78 +++++++++++++++++++++++++++++++++++++---------
>  net/sunrpc/sunrpc_syms.c |    3 ++
>  2 files changed, 65 insertions(+), 16 deletions(-)
> 
> diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
> index 28f50da..1ec4a1a 100644
> --- a/net/sunrpc/rpcb_clnt.c
> +++ b/net/sunrpc/rpcb_clnt.c
> @@ -20,6 +20,7 @@
>  #include <linux/in6.h>
>  #include <linux/kernel.h>
>  #include <linux/errno.h>
> +#include <linux/spinlock.h>
>  #include <net/ipv6.h>
>  
>  #include <linux/sunrpc/clnt.h>
> @@ -110,6 +111,9 @@ static void			rpcb_getport_done(struct rpc_task *, void *);
>  static void			rpcb_map_release(void *data);
>  static struct rpc_program	rpcb_program;
>  
> +static struct rpc_clnt *	rpcb_local_clnt;
> +static struct rpc_clnt *	rpcb_local_clnt4;
> +
>  struct rpcbind_args {
>  	struct rpc_xprt *	r_xprt;
>  
> @@ -163,7 +167,7 @@ static const struct sockaddr_in rpcb_inaddr_loopback = {
>  	.sin_port		= htons(RPCBIND_PORT),
>  };
>  
> -static struct rpc_clnt *rpcb_create_local(u32 version)
> +static int rpcb_create_local(void)
>  {
>  	struct rpc_create_args args = {
>  		.protocol	= XPRT_TRANSPORT_UDP,
> @@ -171,12 +175,37 @@ static struct rpc_clnt *rpcb_create_local(u32 version)
>  		.addrsize	= sizeof(rpcb_inaddr_loopback),
>  		.servername	= "localhost",
>  		.program	= &rpcb_program,
> -		.version	= version,
> +		.version	= RPCBVERS_2,
>  		.authflavor	= RPC_AUTH_UNIX,
>  		.flags		= RPC_CLNT_CREATE_NOPING,
>  	};
> +	static DEFINE_SPINLOCK(rpcb_create_local_lock);
> +	struct rpc_clnt *clnt, *clnt4;
> +	int result = 0;
> +
> +	spin_lock(&rpcb_create_local_lock);
> +	if (rpcb_local_clnt)
> +		goto out;
> +
> +	clnt = rpc_create(&args);
> +	if (IS_ERR(clnt)) {
> +		result = -PTR_ERR(clnt);
> +		goto out;
> +	}
>  
> -	return rpc_create(&args);
> +	clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4);
> +	if (IS_ERR(clnt4)) {
> +		result = -PTR_ERR(clnt4);
> +		rpc_shutdown_client(clnt);
> +		goto out;
> +	}
> +
> +	rpcb_local_clnt = clnt;
> +	rpcb_local_clnt4 = clnt4;
> +
> +out:
> +	spin_unlock(&rpcb_create_local_lock);
> +	return result;
>  }

You can't have tested this. At the very least you cannot have done so
with spinlock debugging enabled...

Trond

  parent reply	other threads:[~2009-11-20 20:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05 18:22 [PATCH 00/11] For 2.6.33 Chuck Lever
     [not found] ` <20091105181924.2796.9313.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2009-11-05 18:22   ` [PATCH 01/11] SUNRPC: Display compressed (shorthand) IPv6 presentation addresses Chuck Lever
2009-11-05 18:22   ` [PATCH 02/11] NFS: Display compressed (shorthand) IPv6 in /proc/mounts Chuck Lever
2009-11-05 18:22   ` [PATCH 03/11] NFS: Revert default r/wsize behavior Chuck Lever
2009-11-05 18:22   ` [PATCH 04/11] SUNRPC: Check explicitly for tk_status == 0 in call_transmit_status() Chuck Lever
2009-11-05 18:23   ` [PATCH 05/11] SUNRPC: Allow RPCs to fail quickly if the server is unreachable Chuck Lever
2009-11-05 18:23   ` [PATCH 06/11] SUNRPC: Simplify synopsis of rpcb_local_clnt() Chuck Lever
2009-11-05 18:23   ` [PATCH 07/11] SUNRPC: Use a cached RPC client and transport for rpcbind upcalls Chuck Lever
     [not found]     ` <20091105182319.2796.62305.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2009-11-20 20:18       ` Trond Myklebust [this message]
2009-11-20 20:19         ` Chuck Lever
2009-11-20 21:50         ` Chuck Lever
2009-11-20 22:05           ` J. Bruce Fields
2009-11-20 22:24             ` Chuck Lever
2009-11-20 22:36               ` J. Bruce Fields
2009-11-20 23:47                 ` Trond Myklebust
2009-11-05 18:23   ` [PATCH 08/11] SUNRPC: Use TCP for local " Chuck Lever
2009-11-05 18:23   ` [PATCH 09/11] SUNRPC: Use soft connects for autobinding over TCP Chuck Lever
2009-11-05 18:23   ` [PATCH 10/11] SUNRPC: Use soft connect semantics when performing RPC ping Chuck Lever
2009-11-05 18:23   ` [PATCH 11/11] SUNRPC: soft connect semantics for UDP Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1258748285.2494.84.camel@localhost \
    --to=trond.myklebust@netapp.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.