diff mbox

net/sunrpc/xprtsock.c: some common code found

Message ID Pine.LNX.4.64.0902062247500.31842@wrl-59.cs.helsinki.fi
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Ilpo Järvinen Feb. 6, 2009, 8:51 p.m. UTC
$ diff-funcs xs_udp_write_space net/sunrpc/xprtsock.c
net/sunrpc/xprtsock.c xs_tcp_write_space
 --- net/sunrpc/xprtsock.c:xs_udp_write_space()
 +++ net/sunrpc/xprtsock.c:xs_tcp_write_space()
@@ -1,4 +1,4 @@
- * xs_udp_write_space - callback invoked when socket buffer space
+ * xs_tcp_write_space - callback invoked when socket buffer space
  *                             becomes available
  * @sk: socket whose state has changed
  *
@@ -7,12 +7,12 @@
  * progress, otherwise we'll waste resources thrashing kernel_sendmsg
  * with a bunch of small requests.
  */
-static void xs_udp_write_space(struct sock *sk)
+static void xs_tcp_write_space(struct sock *sk)
 {
 	read_lock(&sk->sk_callback_lock);

-	/* from net/core/sock.c:sock_def_write_space */
-	if (sock_writeable(sk)) {
+	/* from net/core/stream.c:sk_stream_write_space */
+	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
 		struct socket *sock;
 		struct rpc_xprt *xprt;


$ codiff net/sunrpc/xprtsock.o net/sunrpc/xprtsock.o.new
net/sunrpc/xprtsock.c:
  xs_tcp_write_space | -163
  xs_udp_write_space | -163
 2 functions changed, 326 bytes removed

net/sunrpc/xprtsock.c:
  xs_write_space | +179
 1 function changed, 179 bytes added

net/sunrpc/xprtsock.o.new:
 3 functions changed, 179 bytes added, 326 bytes removed, diff: -147

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
 net/sunrpc/xprtsock.c |   53 +++++++++++++++++++-----------------------------
 1 files changed, 21 insertions(+), 32 deletions(-)

Comments

Ilpo Järvinen Feb. 6, 2009, 8:53 p.m. UTC | #1
Grr, forgot to cc sunrpc maintainer... Added. Just ask if somebody wants 
a complete resend.

On Fri, 6 Feb 2009, Ilpo Järvinen wrote:

> 
> $ diff-funcs xs_udp_write_space net/sunrpc/xprtsock.c
> net/sunrpc/xprtsock.c xs_tcp_write_space
>  --- net/sunrpc/xprtsock.c:xs_udp_write_space()
>  +++ net/sunrpc/xprtsock.c:xs_tcp_write_space()
> @@ -1,4 +1,4 @@
> - * xs_udp_write_space - callback invoked when socket buffer space
> + * xs_tcp_write_space - callback invoked when socket buffer space
>   *                             becomes available
>   * @sk: socket whose state has changed
>   *
> @@ -7,12 +7,12 @@
>   * progress, otherwise we'll waste resources thrashing kernel_sendmsg
>   * with a bunch of small requests.
>   */
> -static void xs_udp_write_space(struct sock *sk)
> +static void xs_tcp_write_space(struct sock *sk)
>  {
>  	read_lock(&sk->sk_callback_lock);
> 
> -	/* from net/core/sock.c:sock_def_write_space */
> -	if (sock_writeable(sk)) {
> +	/* from net/core/stream.c:sk_stream_write_space */
> +	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
>  		struct socket *sock;
>  		struct rpc_xprt *xprt;
> 
> 
> $ codiff net/sunrpc/xprtsock.o net/sunrpc/xprtsock.o.new
> net/sunrpc/xprtsock.c:
>   xs_tcp_write_space | -163
>   xs_udp_write_space | -163
>  2 functions changed, 326 bytes removed
> 
> net/sunrpc/xprtsock.c:
>   xs_write_space | +179
>  1 function changed, 179 bytes added
> 
> net/sunrpc/xprtsock.o.new:
>  3 functions changed, 179 bytes added, 326 bytes removed, diff: -147
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
> ---
>  net/sunrpc/xprtsock.c |   53 +++++++++++++++++++-----------------------------
>  1 files changed, 21 insertions(+), 32 deletions(-)
> 
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index 5cbb404..b49e434 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -1215,6 +1215,23 @@ out:
>  	read_unlock(&sk->sk_callback_lock);
>  }
>  
> +static void xs_write_space(struct sock *sk)
> +{
> +	struct socket *sock;
> +	struct rpc_xprt *xprt;
> +
> +	if (unlikely(!(sock = sk->sk_socket)))
> +		return;
> +	clear_bit(SOCK_NOSPACE, &sock->flags);
> +
> +	if (unlikely(!(xprt = xprt_from_sock(sk))))
> +		return;
> +	if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> +		return;
> +
> +	xprt_write_space(xprt);
> +}
> +
>  /**
>   * xs_udp_write_space - callback invoked when socket buffer space
>   *                             becomes available
> @@ -1230,23 +1247,9 @@ static void xs_udp_write_space(struct sock *sk)
>  	read_lock(&sk->sk_callback_lock);
>  
>  	/* from net/core/sock.c:sock_def_write_space */
> -	if (sock_writeable(sk)) {
> -		struct socket *sock;
> -		struct rpc_xprt *xprt;
> -
> -		if (unlikely(!(sock = sk->sk_socket)))
> -			goto out;
> -		clear_bit(SOCK_NOSPACE, &sock->flags);
> -
> -		if (unlikely(!(xprt = xprt_from_sock(sk))))
> -			goto out;
> -		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> -			goto out;
> -
> -		xprt_write_space(xprt);
> -	}
> +	if (sock_writeable(sk))
> +		xs_write_space(sk);
>  
> - out:
>  	read_unlock(&sk->sk_callback_lock);
>  }
>  
> @@ -1265,23 +1268,9 @@ static void xs_tcp_write_space(struct sock *sk)
>  	read_lock(&sk->sk_callback_lock);
>  
>  	/* from net/core/stream.c:sk_stream_write_space */
> -	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
> -		struct socket *sock;
> -		struct rpc_xprt *xprt;
> -
> -		if (unlikely(!(sock = sk->sk_socket)))
> -			goto out;
> -		clear_bit(SOCK_NOSPACE, &sock->flags);
> +	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
> +		xs_write_space(sk);
>  
> -		if (unlikely(!(xprt = xprt_from_sock(sk))))
> -			goto out;
> -		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> -			goto out;
> -
> -		xprt_write_space(xprt);
> -	}
> -
> - out:
>  	read_unlock(&sk->sk_callback_lock);
>  }
>  
>
J. Bruce Fields Feb. 6, 2009, 9:20 p.m. UTC | #2
On Fri, Feb 06, 2009 at 10:53:32PM +0200, Ilpo Järvinen wrote:
> Grr, forgot to cc sunrpc maintainer... Added. Just ask if somebody wants
> a complete resend.

You probably wanted Trond, actually.  (And did this patch have a
changelog?)

--b.

> 
> On Fri, 6 Feb 2009, Ilpo Järvinen wrote:
> 
> >
> > $ diff-funcs xs_udp_write_space net/sunrpc/xprtsock.c
> > net/sunrpc/xprtsock.c xs_tcp_write_space
> >  --- net/sunrpc/xprtsock.c:xs_udp_write_space()
> >  +++ net/sunrpc/xprtsock.c:xs_tcp_write_space()
> > @@ -1,4 +1,4 @@
> > - * xs_udp_write_space - callback invoked when socket buffer space
> > + * xs_tcp_write_space - callback invoked when socket buffer space
> >   *                             becomes available
> >   * @sk: socket whose state has changed
> >   *
> > @@ -7,12 +7,12 @@
> >   * progress, otherwise we'll waste resources thrashing kernel_sendmsg
> >   * with a bunch of small requests.
> >   */
> > -static void xs_udp_write_space(struct sock *sk)
> > +static void xs_tcp_write_space(struct sock *sk)
> >  {
> >  	read_lock(&sk->sk_callback_lock);
> >
> > -	/* from net/core/sock.c:sock_def_write_space */
> > -	if (sock_writeable(sk)) {
> > +	/* from net/core/stream.c:sk_stream_write_space */
> > +	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
> >  		struct socket *sock;
> >  		struct rpc_xprt *xprt;
> >
> >
> > $ codiff net/sunrpc/xprtsock.o net/sunrpc/xprtsock.o.new
> > net/sunrpc/xprtsock.c:
> >   xs_tcp_write_space | -163
> >   xs_udp_write_space | -163
> >  2 functions changed, 326 bytes removed
> >
> > net/sunrpc/xprtsock.c:
> >   xs_write_space | +179
> >  1 function changed, 179 bytes added
> >
> > net/sunrpc/xprtsock.o.new:
> >  3 functions changed, 179 bytes added, 326 bytes removed, diff: -147
> >
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
> > ---
> >  net/sunrpc/xprtsock.c |   53 +++++++++++++++++++-----------------------------
> >  1 files changed, 21 insertions(+), 32 deletions(-)
> >
> > diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> > index 5cbb404..b49e434 100644
> > --- a/net/sunrpc/xprtsock.c
> > +++ b/net/sunrpc/xprtsock.c
> > @@ -1215,6 +1215,23 @@ out:
> >  	read_unlock(&sk->sk_callback_lock);
> >  }
> >
> > +static void xs_write_space(struct sock *sk)
> > +{
> > +	struct socket *sock;
> > +	struct rpc_xprt *xprt;
> > +
> > +	if (unlikely(!(sock = sk->sk_socket)))
> > +		return;
> > +	clear_bit(SOCK_NOSPACE, &sock->flags);
> > +
> > +	if (unlikely(!(xprt = xprt_from_sock(sk))))
> > +		return;
> > +	if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> > +		return;
> > +
> > +	xprt_write_space(xprt);
> > +}
> > +
> >  /**
> >   * xs_udp_write_space - callback invoked when socket buffer space
> >   *                             becomes available
> > @@ -1230,23 +1247,9 @@ static void xs_udp_write_space(struct sock *sk)
> >  	read_lock(&sk->sk_callback_lock);
> >
> >  	/* from net/core/sock.c:sock_def_write_space */
> > -	if (sock_writeable(sk)) {
> > -		struct socket *sock;
> > -		struct rpc_xprt *xprt;
> > -
> > -		if (unlikely(!(sock = sk->sk_socket)))
> > -			goto out;
> > -		clear_bit(SOCK_NOSPACE, &sock->flags);
> > -
> > -		if (unlikely(!(xprt = xprt_from_sock(sk))))
> > -			goto out;
> > -		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> > -			goto out;
> > -
> > -		xprt_write_space(xprt);
> > -	}
> > +	if (sock_writeable(sk))
> > +		xs_write_space(sk);
> >
> > - out:
> >  	read_unlock(&sk->sk_callback_lock);
> >  }
> >
> > @@ -1265,23 +1268,9 @@ static void xs_tcp_write_space(struct sock *sk)
> >  	read_lock(&sk->sk_callback_lock);
> >
> >  	/* from net/core/stream.c:sk_stream_write_space */
> > -	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
> > -		struct socket *sock;
> > -		struct rpc_xprt *xprt;
> > -
> > -		if (unlikely(!(sock = sk->sk_socket)))
> > -			goto out;
> > -		clear_bit(SOCK_NOSPACE, &sock->flags);
> > +	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
> > +		xs_write_space(sk);
> >
> > -		if (unlikely(!(xprt = xprt_from_sock(sk))))
> > -			goto out;
> > -		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
> > -			goto out;
> > -
> > -		xprt_write_space(xprt);
> > -	}
> > -
> > - out:
> >  	read_unlock(&sk->sk_callback_lock);
> >  }
> >
> > 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Feb. 6, 2009, 10:07 p.m. UTC | #3
From: "J. Bruce Fields" <bfields@fieldses.org>
Date: Fri, 6 Feb 2009 16:20:43 -0500

> On Fri, Feb 06, 2009 at 10:53:32PM +0200, Ilpo Järvinen wrote:
> > Grr, forgot to cc sunrpc maintainer... Added. Just ask if somebody wants
> > a complete resend.
> 
> You probably wanted Trond, actually.  (And did this patch have a
> changelog?)

Open your eyes :-)  That first "diff" you see is part of the
commit message not the patch itself.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Feb. 7, 2009, 7:49 a.m. UTC | #4
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Fri, 6 Feb 2009 22:51:17 +0200 (EET)

> 
> $ diff-funcs xs_udp_write_space net/sunrpc/xprtsock.c
...
> $ codiff net/sunrpc/xprtsock.o net/sunrpc/xprtsock.o.new
> net/sunrpc/xprtsock.c:
>   xs_tcp_write_space | -163
>   xs_udp_write_space | -163
>  2 functions changed, 326 bytes removed
> 
> net/sunrpc/xprtsock.c:
>   xs_write_space | +179
>  1 function changed, 179 bytes added
> 
> net/sunrpc/xprtsock.o.new:
>  3 functions changed, 179 bytes added, 326 bytes removed, diff: -147
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 5cbb404..b49e434 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1215,6 +1215,23 @@  out:
 	read_unlock(&sk->sk_callback_lock);
 }
 
+static void xs_write_space(struct sock *sk)
+{
+	struct socket *sock;
+	struct rpc_xprt *xprt;
+
+	if (unlikely(!(sock = sk->sk_socket)))
+		return;
+	clear_bit(SOCK_NOSPACE, &sock->flags);
+
+	if (unlikely(!(xprt = xprt_from_sock(sk))))
+		return;
+	if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
+		return;
+
+	xprt_write_space(xprt);
+}
+
 /**
  * xs_udp_write_space - callback invoked when socket buffer space
  *                             becomes available
@@ -1230,23 +1247,9 @@  static void xs_udp_write_space(struct sock *sk)
 	read_lock(&sk->sk_callback_lock);
 
 	/* from net/core/sock.c:sock_def_write_space */
-	if (sock_writeable(sk)) {
-		struct socket *sock;
-		struct rpc_xprt *xprt;
-
-		if (unlikely(!(sock = sk->sk_socket)))
-			goto out;
-		clear_bit(SOCK_NOSPACE, &sock->flags);
-
-		if (unlikely(!(xprt = xprt_from_sock(sk))))
-			goto out;
-		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
-			goto out;
-
-		xprt_write_space(xprt);
-	}
+	if (sock_writeable(sk))
+		xs_write_space(sk);
 
- out:
 	read_unlock(&sk->sk_callback_lock);
 }
 
@@ -1265,23 +1268,9 @@  static void xs_tcp_write_space(struct sock *sk)
 	read_lock(&sk->sk_callback_lock);
 
 	/* from net/core/stream.c:sk_stream_write_space */
-	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
-		struct socket *sock;
-		struct rpc_xprt *xprt;
-
-		if (unlikely(!(sock = sk->sk_socket)))
-			goto out;
-		clear_bit(SOCK_NOSPACE, &sock->flags);
+	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+		xs_write_space(sk);
 
-		if (unlikely(!(xprt = xprt_from_sock(sk))))
-			goto out;
-		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
-			goto out;
-
-		xprt_write_space(xprt);
-	}
-
- out:
 	read_unlock(&sk->sk_callback_lock);
 }