linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Anna Schumaker <anna.schumaker@netapp.com>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH v2 04/10] SUNRPC: extract xs_stream_reset_state()
Date: Fri,  7 Oct 2016 11:01:48 +0100	[thread overview]
Message-ID: <1475834514-4058-5-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1475834514-4058-1-git-send-email-stefanha@redhat.com>

Extract a function to reset the record fragment parser.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 net/sunrpc/xprtsock.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 62a8ec6..dfdce75 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1538,6 +1538,28 @@ static void xs_stream_data_receive_workfn(struct work_struct *work)
 }
 
 /**
+ * xs_stream_reset_state - reset SOCK_STREAM record parser
+ * @transport: socket transport
+ * @read_sock: tcp_read_sock()-like function
+ *
+ */
+static void xs_stream_reset_state(struct rpc_xprt *xprt,
+				  int (*read_sock)(struct sock *,
+						   read_descriptor_t *,
+						   sk_read_actor_t))
+{
+	struct sock_xprt *transport = container_of(xprt,
+			struct sock_xprt, xprt);
+
+	transport->stream_offset = 0;
+	transport->stream_reclen = 0;
+	transport->stream_copied = 0;
+	transport->stream_flags =
+		STREAM_RCV_COPY_FRAGHDR | STREAM_RCV_COPY_XID;
+	transport->stream_read_sock = read_sock;
+}
+
+/**
  * xs_tcp_state_change - callback to handle TCP socket state changes
  * @sk: socket whose state has changed
  *
@@ -1563,14 +1585,7 @@ static void xs_tcp_state_change(struct sock *sk)
 	case TCP_ESTABLISHED:
 		spin_lock(&xprt->transport_lock);
 		if (!xprt_test_and_set_connected(xprt)) {
-
-			/* Reset stream record info */
-			transport->stream_offset = 0;
-			transport->stream_reclen = 0;
-			transport->stream_copied = 0;
-			transport->stream_flags =
-				STREAM_RCV_COPY_FRAGHDR | STREAM_RCV_COPY_XID;
-			transport->stream_read_sock = tcp_read_sock;
+			xs_stream_reset_state(xprt, tcp_read_sock);
 			xprt->connect_cookie++;
 			clear_bit(XPRT_SOCK_CONNECTING, &transport->sock_state);
 			xprt_clear_connecting(xprt);
-- 
2.7.4


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

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07 10:01 [PATCH v2 00/10] NFS: add AF_VSOCK support to NFS client Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 01/10] SUNRPC: add AF_VSOCK support to addr.[ch] Stefan Hajnoczi
2016-10-07 15:15   ` Chuck Lever
2016-10-21 13:04     ` Stefan Hajnoczi
2016-10-21 14:22       ` Chuck Lever
2017-05-18 14:04   ` Jeff Layton
2017-05-22 12:21     ` Stefan Hajnoczi
2017-05-22 12:54       ` Jeff Layton
2017-05-23 13:11         ` Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 02/10] SUNRPC: rename "TCP" record parser to "stream" parser Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 03/10] SUNRPC: abstract tcp_read_sock() in record fragment parser Stefan Hajnoczi
2016-10-07 10:01 ` Stefan Hajnoczi [this message]
2016-10-07 10:01 ` [PATCH v2 05/10] VSOCK: add tcp_read_sock()-like vsock_read_sock() function Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 06/10] SUNRPC: add AF_VSOCK support to xprtsock.c Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 07/10] SUNRPC: drop unnecessary svc_bc_tcp_create() helper Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 08/10] SUNRPC: add AF_VSOCK support to svc_xprt.c Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 09/10] SUNRPC: add AF_VSOCK backchannel support Stefan Hajnoczi
2016-10-07 10:01 ` [PATCH v2 10/10] NFS: add AF_VSOCK support to NFS client Stefan Hajnoczi
2016-10-08  0:42 ` [PATCH v2 00/10] " Cedric Blancher
2016-10-20 14:36   ` Stefan Hajnoczi
2016-10-27  1:05     ` Cedric Blancher
2016-11-30 10:21       ` Stefan Hajnoczi

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=1475834514-4058-5-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=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).