Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7927238rwp; Wed, 19 Jul 2023 02:29:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEy+DCDeCgN6r1dvpkP7o4rTiYBOCy57BKI9lOtViZyUkQhuW73uNdCINrYl5dFwwtChWfG X-Received: by 2002:a05:6358:6f97:b0:134:cb65:fbbe with SMTP id s23-20020a0563586f9700b00134cb65fbbemr14104231rwn.13.1689758956007; Wed, 19 Jul 2023 02:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689758955; cv=none; d=google.com; s=arc-20160816; b=DoLJTJhSH8+3vB889lNc/G0THkgONJpEZtO4C/ZH1aBDwEgmO4u4wewElL2F0oHwqf JekS3ibaviXqXeTM7FsgfEwkLhGb9kAKxFJK8AS8q8xP3Fh1ZkdjGmnhPR9uiykrFzqT A8EMd+hBMqN2ZS33BUyNM3PBGIWxqhOV6p8LLaRr9qvhVsNF3HDhiphtSuNIDjrwpQu+ jrPjOvm4wd4ocFNV+vLdT5dcnEG7naiQBlKVNyyUUEFAkZ9DZaRoQX2DYyKZjRSsg3e1 RZntKmmOpyNLryyjKIshtViH1solRkJA75piWgKsxp1dhloF82GNUk459vfuweWfSbM0 RPag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=aMIgzXiT1F2iEJnG15o5FqJ6MShjQORJM5LN2yDl3KI=; fh=mpgiWSi1NxVhjU0VI0jxYPFQIsMtO0bR9SOGHL6KuFI=; b=We+GsbkeMb1nEvkakCLfWfRf4Apy/bsRIIbU/w7+s3YqKSImHZi5ZDiqpa2B7AWGLH DmlahaXjM5GGYQm+QFtvO9PTgmcCkByRAE5tz6Phd0IE+6Detlu1Dbm//5QbfbaN4Lux vctYizE2ecL0sFZQ3M/QAsav1xcG6ZWHClyGel3y3LUqidFAf1OdLC/qIR3sO/63GSHv ygMFKjJQ4hkH+NASg8k0yb5ZKLilqUPXHFTKEDRY1Vfd4HtujvD/kqGVCftOGbILrN46 ebDHa+aJ4M1NR3fmh5COrFO6fz03BofjRuPpKeyBRLqS/rQwYbOL9Uo4h7V9U6ShNuLo xUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aJQtS3NO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m66-20020a632645000000b005538fc7243asi3175272pgm.507.2023.07.19.02.29.01; Wed, 19 Jul 2023 02:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aJQtS3NO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbjGSJK5 (ORCPT + 99 others); Wed, 19 Jul 2023 05:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjGSJKz (ORCPT ); Wed, 19 Jul 2023 05:10:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C287E134 for ; Wed, 19 Jul 2023 02:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689757815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aMIgzXiT1F2iEJnG15o5FqJ6MShjQORJM5LN2yDl3KI=; b=aJQtS3NO2hYHYF/3bv13bvEDsTmrbU+7uffuykWZVdLAsnYpi8ezRwHZQKVt+oGBzIhSkM TLoFisY361TvJfJfVS7HBpdD7tdmnaRj+FfMjvlWo96LWDkR40LIlsONRqzSUz6lOQ8hXo bY2XJEN9g60RoEeNHCDz+8MHji+K7Zg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-WzdpLWmjPkmtkdFW_z-X1A-1; Wed, 19 Jul 2023 05:10:11 -0400 X-MC-Unique: WzdpLWmjPkmtkdFW_z-X1A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28B5688D580; Wed, 19 Jul 2023 09:10:11 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.45.225.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6ADBF6CCA; Wed, 19 Jul 2023 09:10:09 +0000 (UTC) From: Jan Stancek To: dhowells@redhat.com, kuba@kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, brauner@kernel.org, viro@zeniv.linux.org.uk, jstancek@redhat.com Subject: [PATCH] splice, net: Fix splice_to_socket() for O_NONBLOCK socket Date: Wed, 19 Jul 2023 11:07:52 +0200 Message-Id: <7854000d2ce5ac32b75782a7c4574f25a11b573d.1689757133.git.jstancek@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LTP sendfile07 [1], which expects sendfile() to return EAGAIN when transferring data from regular file to a "full" O_NONBLOCK socket, started failing after commit 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()"). sendfile() no longer immediately returns, but now blocks. Removed sock_sendpage() handled this case by setting a MSG_DONTWAIT flag, fix new splice_to_socket() to do the same for O_NONBLOCK sockets. [1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/sendfile/sendfile07.c Fixes: 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()") Signed-off-by: Jan Stancek --- fs/splice.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index 004eb1c4ce31..3e2a31e1ce6a 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -876,6 +876,8 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out, msg.msg_flags |= MSG_MORE; if (remain && pipe_occupancy(pipe->head, tail) > 0) msg.msg_flags |= MSG_MORE; + if (out->f_flags & O_NONBLOCK) + msg.msg_flags |= MSG_DONTWAIT; iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, bvec, bc, len - remain); -- 2.31.1