linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 09/10] SUNRPC: Change TCP socket space reservation
Date: Wed, 6 Jul 2016 15:53:08 -0400	[thread overview]
Message-ID: <20160706195308.GF18856@fieldses.org> (raw)
In-Reply-To: <1466780152-7154-9-git-send-email-trond.myklebust@primarydata.com>

On Fri, Jun 24, 2016 at 10:55:51AM -0400, Trond Myklebust wrote:
> Instead of trying (and failing) to predict how much writeable socket space
> will be available to the RPC call, just fall back to the simple model of
> deferring processing until the socket is uncongested.
> 
> If a limit is neeeded, then set the hard per-connection limit.

I was hoping this would be an opportunity to get rid of even more code,
but there's still the udp case.  Do we actually need that?

--b.


> 
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
>  net/sunrpc/svcsock.c | 47 ++++-------------------------------------------
>  1 file changed, 4 insertions(+), 43 deletions(-)
> 
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 338d6fe1103d..bc3ef0734f2f 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -431,43 +431,11 @@ static void svc_write_space(struct sock *sk)
>  
>  static int svc_tcp_has_wspace(struct svc_xprt *xprt)
>  {
> -	struct svc_sock *svsk =	container_of(xprt, struct svc_sock, sk_xprt);
> -	struct svc_serv *serv = svsk->sk_xprt.xpt_server;
> -	int required;
> +	struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt);
>  
>  	if (test_bit(XPT_LISTENER, &xprt->xpt_flags))
>  		return 1;
> -	required = atomic_read(&xprt->xpt_reserved) + serv->sv_max_mesg;
> -	if (sk_stream_wspace(svsk->sk_sk) >= required ||
> -	    (sk_stream_min_wspace(svsk->sk_sk) == 0 &&
> -	     atomic_read(&xprt->xpt_reserved) == 0))
> -		return 1;
> -	set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
> -	return 0;
> -}
> -
> -static void svc_tcp_write_space(struct sock *sk)
> -{
> -	struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data);
> -	struct socket *sock = sk->sk_socket;
> -
> -	if (!svsk)
> -		return;
> -
> -	if (!sk_stream_is_writeable(sk) || !sock)
> -		return;
> -	if (svc_tcp_has_wspace(&svsk->sk_xprt)) {
> -		clear_bit(SOCK_NOSPACE, &sock->flags);
> -		svc_write_space(sk);
> -	}
> -}
> -
> -static void svc_tcp_adjust_wspace(struct svc_xprt *xprt)
> -{
> -	struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt);
> -
> -	if (svc_tcp_has_wspace(xprt))
> -		clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
> +	return !test_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
>  }
>  
>  /*
> @@ -1272,7 +1240,6 @@ static struct svc_xprt_ops svc_tcp_ops = {
>  	.xpo_has_wspace = svc_tcp_has_wspace,
>  	.xpo_accept = svc_tcp_accept,
>  	.xpo_secure_port = svc_sock_secure_port,
> -	.xpo_adjust_wspace = svc_tcp_adjust_wspace,
>  };
>  
>  static struct svc_xprt_class svc_tcp_class = {
> @@ -1313,7 +1280,7 @@ static void svc_tcp_init(struct svc_sock *svsk, struct svc_serv *serv)
>  		dprintk("setting up TCP socket for reading\n");
>  		sk->sk_state_change = svc_tcp_state_change;
>  		sk->sk_data_ready = svc_data_ready;
> -		sk->sk_write_space = svc_tcp_write_space;
> +		sk->sk_write_space = svc_write_space;
>  
>  		svsk->sk_reclen = 0;
>  		svsk->sk_tcplen = 0;
> @@ -1383,14 +1350,8 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
>  	/* Initialize the socket */
>  	if (sock->type == SOCK_DGRAM)
>  		svc_udp_init(svsk, serv);
> -	else {
> -		/* initialise setting must have enough space to
> -		 * receive and respond to one request.
> -		 */
> -		svc_sock_setbufsize(svsk->sk_sock, 4 * serv->sv_max_mesg,
> -					4 * serv->sv_max_mesg);
> +	else
>  		svc_tcp_init(svsk, serv);
> -	}
>  
>  	dprintk("svc: svc_setup_socket created %p (inet %p)\n",
>  				svsk, svsk->sk_sk);
> -- 
> 2.7.4

  parent reply	other threads:[~2016-07-06 19:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 14:55 [PATCH 01/10] SUNRPC: Fix tracepoint storage issues with svc_recv and svc_rqst_status Trond Myklebust
2016-06-24 14:55 ` [PATCH 02/10] SUNRPC: Don't allocate a full sockaddr_storage for tracing Trond Myklebust
2016-06-24 14:55   ` [PATCH 03/10] SUNRPC: Add a tracepoint for server socket out-of-space conditions Trond Myklebust
2016-06-24 14:55     ` [PATCH 04/10] SUNRPC: Add tracepoints for dropped and deferred requests Trond Myklebust
2016-06-24 14:55       ` [PATCH 05/10] SUNRPC: lock the socket while detaching it Trond Myklebust
2016-06-24 14:55         ` [PATCH 06/10] SUNRPC: Call the default socket callbacks instead of open coding Trond Myklebust
2016-06-24 14:55           ` [PATCH 07/10] SUNRPC: Micro optimisation for svc_data_ready Trond Myklebust
2016-06-24 14:55             ` [PATCH 08/10] SUNRPC: Add a server side per-connection limit Trond Myklebust
2016-06-24 14:55               ` [PATCH 09/10] SUNRPC: Change TCP socket space reservation Trond Myklebust
2016-06-24 14:55                 ` [PATCH 10/10] SUNRPC: Remove unused callback xpo_adjust_wspace() Trond Myklebust
2016-06-24 21:18                 ` [PATCH 09/10] SUNRPC: Change TCP socket space reservation J. Bruce Fields
2016-06-24 21:31                   ` Trond Myklebust
2016-07-06 20:17                     ` Fields Bruce
2016-07-06 19:53                 ` J. Bruce Fields [this message]
2016-07-06 20:11                   ` Trond Myklebust
2016-07-06 20:30                     ` Fields Bruce
2016-06-24 21:15               ` [PATCH 08/10] SUNRPC: Add a server side per-connection limit J. Bruce Fields
2016-06-24 21:24                 ` Trond Myklebust
2016-07-06 16:16               ` J. Bruce Fields
2016-06-24 21:06         ` [PATCH 05/10] SUNRPC: lock the socket while detaching it J. Bruce Fields
2016-06-24 21:21           ` Trond Myklebust
2016-06-24 18:28 ` [PATCH 01/10] SUNRPC: Fix tracepoint storage issues with svc_recv and svc_rqst_status J. Bruce Fields

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=20160706195308.GF18856@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).