From patchwork Mon Oct 16 20:35:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 153753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3711887vqb; Mon, 16 Oct 2023 13:37:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlR6Wf7sEezVxR+Elwe4CMV8aSk/qUx9suE8NFzpinMVvAbFKDq1+mxn8T+2jPF3KjZZ1o X-Received: by 2002:a05:6a20:8f2a:b0:163:d382:ba84 with SMTP id b42-20020a056a208f2a00b00163d382ba84mr156351pzk.5.1697488619893; Mon, 16 Oct 2023 13:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697488619; cv=none; d=google.com; s=arc-20160816; b=LY1CO7p4j3K1obzfAjYlWbet4w0LmN9o3s6RMbFHleSiG3xeo5iQ9Y+wh+Z4opXTWD BwGnjd7SWLbEl1G2evehL42VVC3qILe5GiSdS8i3af7n+xV+VlE3nJPJeQAnjWpWLu+j ViVkYngl1tvYXyb+Vi//tGrlViLbMhQDpXPsK6mfyUamNO8vA+bEveCZSSDMx5/nDsYp 9KuS38O5qZ0g+LL/cD05liDXiCY+l75M1EKbQk39H904r5+SmgAaboGt58qvjyPBPXJk 6WV4v4ldlDZwZ/M4gfWs080+kqC1xLKcM0HFChnoiHqEpYVW/2b8QhykAhZnU6dqHXRy yyMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:from:date :dkim-signature; bh=l1PtJSN/I8m3vayh5hsywgRFHMsj8/pw5wAcw0S5/Zw=; fh=KwZ3wEPimNjBeMiHhaOl2Rz8VAJi6umDd4UaHqS5lCo=; b=pbMiDnziiWYvd3W8n0jwQ6FTAQ3HhAaj5eP+lzAb/yajUmTN8RKkMJGPYFvBrE7BNc golCkcujd5opMeaF4S++jcrJQeG6tUdE5ezeJTv30uvxmesffjTprxZo78Uthk5n9bly TnuZXN4g6b9Y5EyNHDSP+xWMOiqC3m7WNcnffwDfoCSjbYytZl9ylsUfSUX4jg2OZBbC nLyzNmSaLQP4cyKITmF8U1WioCX+S7/ecz2QXNXBgFXwebz2KMJQW4oPJm/A4ccutfkt Z5yYA8QhmxBSx4ZFsP+q2pzuOASCjOl55JlqgxVBlgMe48HNsWosjrRzqHV6nlAzoWfG DYtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=UmpOEYPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x18-20020a17090300d200b001c60d334996si74054plc.622.2023.10.16.13.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=UmpOEYPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id ACC3B8021EED; Mon, 16 Oct 2023 13:36:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232817AbjJPUgc (ORCPT + 18 others); Mon, 16 Oct 2023 16:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234235AbjJPUgK (ORCPT ); Mon, 16 Oct 2023 16:36:10 -0400 Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A20A181; Mon, 16 Oct 2023 13:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1697488557; bh=9/Rch1NNnuQcxUUP1sdNlrNNgx7qX1hxKSFQK/3R+Pg=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=UmpOEYPJlFLiL4ag5qI+r8wZnOjdoxGBe9TfIsmDRZajgouiqNxZIFuEPmq0+t0dQ XjWhFPb64jAe3/1/E7WKRc3Ygdb9pGYU9if2p7IqdndK6KJ8GrBb53XK4WCsLpu78l GkAyuT4vdjDak/FatVvwXqPcKN4WjZDqSOHGvfLI7AR6N5xvSSbf53N0/Iji9xRtnR YZyvcwA2KvsCuVaMmxmXgyCAVFZg/LCrx6pFjfeVTSfwIr2c6FcaMOiFhJXsYe/5rk pfiDdyRNRKP+LR0YKcUBN668YPC9vsuIw7Sipc9Wiq9fw+t6hPM/0XI05F9OErBe36 1sb5wxpR2oNXg== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 043D71041C; Mon, 16 Oct 2023 22:35:57 +0200 (CEST) Date: Mon, 16 Oct 2023 22:35:56 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Eric Dumazet , "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/11] net/tcp: tcp_splice_read: always do non-blocking reads Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20231006 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 13:36:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779945827179300182 X-GMAIL-MSGID: 1779945827179300182 Otherwise we risk sleeping with the pipe locked for indeterminate lengths of time. sock_rcvtimeo() returns 0 if the second argument is true, so the explicit re-try loop for empty read conditions can be removed entirely. Link: https://lore.kernel.org/linux-fsdevel/qk6hjuam54khlaikf2ssom6custxf5is2ekkaequf4hvode3ls@zgf7j5j4ubvw/t/#u Signed-off-by: Ahelenia ZiemiaƄska --- net/ipv4/tcp.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 3f66cdeef7de..09b562e2c1bf 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -782,7 +782,6 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, .len = len, .flags = flags, }; - long timeo; ssize_t spliced; int ret; @@ -797,7 +796,6 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, lock_sock(sk); - timeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK); while (tss.len) { ret = __tcp_splice_read(sk, &tss); if (ret < 0) @@ -821,35 +819,13 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, ret = -ENOTCONN; break; } - if (!timeo) { - ret = -EAGAIN; - break; - } - /* if __tcp_splice_read() got nothing while we have - * an skb in receive queue, we do not want to loop. - * This might happen with URG data. - */ - if (!skb_queue_empty(&sk->sk_receive_queue)) - break; - sk_wait_data(sk, &timeo, NULL); - if (signal_pending(current)) { - ret = sock_intr_errno(timeo); - break; - } - continue; + ret = -EAGAIN; + break; } tss.len -= ret; spliced += ret; - if (!tss.len || !timeo) - break; - release_sock(sk); - lock_sock(sk); - - if (sk->sk_err || sk->sk_state == TCP_CLOSE || - (sk->sk_shutdown & RCV_SHUTDOWN) || - signal_pending(current)) - break; + break; } release_sock(sk);