From patchwork Fri Oct 7 10:01:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9365935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5578660752 for ; Fri, 7 Oct 2016 10:06:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4580A2949C for ; Fri, 7 Oct 2016 10:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39E772949E; Fri, 7 Oct 2016 10:06:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE9892949C for ; Fri, 7 Oct 2016 10:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684AbcJGKG1 (ORCPT ); Fri, 7 Oct 2016 06:06:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbcJGKG0 (ORCPT ); Fri, 7 Oct 2016 06:06:26 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CBA9C00B71D; Fri, 7 Oct 2016 10:06:26 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97A68St026207; Fri, 7 Oct 2016 06:06:17 -0400 From: Stefan Hajnoczi To: linux-nfs@vger.kernel.org Cc: Anna Schumaker , "J. Bruce Fields" , Trond Myklebust , Stefan Hajnoczi Subject: [PATCH v2 03/10] SUNRPC: abstract tcp_read_sock() in record fragment parser Date: Fri, 7 Oct 2016 11:01:47 +0100 Message-Id: <1475834514-4058-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1475834514-4058-1-git-send-email-stefanha@redhat.com> References: <1475834514-4058-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 07 Oct 2016 10:06:26 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use a function pointer to abstract tcp_read_sock()-like functions. For TCP this function will be tcp_read_sock(). For AF_VSOCK it will be vsock_read_sock(). Signed-off-by: Stefan Hajnoczi --- include/linux/sunrpc/xprtsock.h | 5 +++++ net/sunrpc/xprtsock.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h index db4c88c..bb290b5 100644 --- a/include/linux/sunrpc/xprtsock.h +++ b/include/linux/sunrpc/xprtsock.h @@ -9,6 +9,8 @@ #ifdef __KERNEL__ +#include /* for sk_read_actor_t */ + int init_socket_xprt(void); void cleanup_socket_xprt(void); @@ -39,6 +41,9 @@ struct sock_xprt { unsigned long stream_copied, stream_flags; + int (*stream_read_sock)(struct sock *, + read_descriptor_t *, + sk_read_actor_t); /* * Connection of transports diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 70eb917..62a8ec6 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1493,7 +1493,7 @@ static int xs_stream_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, return len - desc.count; } -static void xs_tcp_data_receive(struct sock_xprt *transport) +static void xs_stream_data_receive(struct sock_xprt *transport) { struct rpc_xprt *xprt = &transport->xprt; struct sock *sk; @@ -1509,10 +1509,11 @@ static void xs_tcp_data_receive(struct sock_xprt *transport) if (sk == NULL) goto out; - /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */ + /* We use rd_desc to pass struct xprt to xs_stream_data_recv */ for (;;) { lock_sock(sk); - read = tcp_read_sock(sk, &rd_desc, xs_stream_data_recv); + read = transport->stream_read_sock(sk, &rd_desc, + xs_stream_data_recv); if (read <= 0) { clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); release_sock(sk); @@ -1529,11 +1530,11 @@ out: trace_xs_tcp_data_ready(xprt, read, total); } -static void xs_tcp_data_receive_workfn(struct work_struct *work) +static void xs_stream_data_receive_workfn(struct work_struct *work) { struct sock_xprt *transport = container_of(work, struct sock_xprt, recv_worker); - xs_tcp_data_receive(transport); + xs_stream_data_receive(transport); } /** @@ -1569,6 +1570,7 @@ static void xs_tcp_state_change(struct sock *sk) transport->stream_copied = 0; transport->stream_flags = STREAM_RCV_COPY_FRAGHDR | STREAM_RCV_COPY_XID; + transport->stream_read_sock = tcp_read_sock; xprt->connect_cookie++; clear_bit(XPRT_SOCK_CONNECTING, &transport->sock_state); xprt_clear_connecting(xprt); @@ -2995,7 +2997,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) xprt->max_reconnect_timeout = xprt->timeout->to_maxval; - INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn); + INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket); switch (addr->sa_family) {