From patchwork Thu Jun 4 16:45:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 6548181 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EEDCFC0020 for ; Thu, 4 Jun 2015 16:46:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A85320792 for ; Thu, 4 Jun 2015 16:46:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A8A520791 for ; Thu, 4 Jun 2015 16:46:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932153AbbFDQqI (ORCPT ); Thu, 4 Jun 2015 12:46:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53808 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932087AbbFDQqF (ORCPT ); Thu, 4 Jun 2015 12:46:05 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 43B2FC1F10; Thu, 4 Jun 2015 16:46:05 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t54Gk3ni006845; Thu, 4 Jun 2015 12:46:04 -0400 From: Stefan Hajnoczi To: linux-nfs@vger.kernel.org Cc: Anna Schumaker , "J. Bruce Fields" , Trond Myklebust , asias.hejun@gmail.com, netdev@vger.kernel.org, Daniel Berrange , "David S. Miller" , Stefan Hajnoczi Subject: [RFC 04/10] SUNRPC: extract xs_stream_reset_state() Date: Thu, 4 Jun 2015 17:45:47 +0100 Message-Id: <1433436353-6761-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1433436353-6761-1-git-send-email-stefanha@redhat.com> References: <1433436353-6761-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Extract a function to reset the record fragment parser. Signed-off-by: Stefan Hajnoczi --- net/sunrpc/xprtsock.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 06fde0e..9fa63f7 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1431,6 +1431,28 @@ out: } /** + * 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 * @@ -1454,16 +1476,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)) { - struct sock_xprt *transport = container_of(xprt, - struct sock_xprt, 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++; xprt_wake_pending_tasks(xprt, -EAGAIN);