Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp308742rwd; Fri, 19 May 2023 21:05:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZZPxPBAoldsV36jCC27SOnyi4w+7FXm8A9I5I1v/6vg2ODrxYP2URNAaujNGiRyqE6Abr X-Received: by 2002:a17:90a:8c08:b0:253:44e7:9446 with SMTP id a8-20020a17090a8c0800b0025344e79446mr4229351pjo.8.1684555501121; Fri, 19 May 2023 21:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684555501; cv=none; d=google.com; s=arc-20160816; b=ISQmHjyZcrn2jtcGp+z51ZC5fYx0i1p86T6A+PITElSGbaPXStz1Q8sQdozuMTCkXh FBns/A87hITqQW6i+bx/IBDGp5EujQl7A/elZ3OHmTr/dEcT7Vx+v9SFvhVhvL1wxYDt ky65lCtMEvlrrM7n/gxouGibsyeGG/d2N7d45dCbSj5G6h23Shn/9GnjAHWkLj2/8lfB eqaSvSWZ5yVp/Fs19lLmxojTHbRamhKUc/2QEKTjTN8P5lxoyC5jnIu+hFnIhf6LGGzS 0U0NQ2Olgj1COcLXfYd/FCDuXWdDmX1+Og1EXAv4hiWhjYXLDip6d6CW1NdfByRZT5wH 5Gew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oL9McTatLzHAnvigXeTVcWUVg0VQVXOaPT42iNyRB/I=; b=CtSABizny1QKJvFbY27XH83XYCg1lRk63dU0RQgnxKW4m6dzDp0SNh3DeWwuzAXiCJ ADWpJrn0H3o3ytuwmAgTq2uJb2Y4jL9sq3fmaD3vQ5x5DEFJyno0XFgK9DDmeskC1j3/ A0ku22ftbgiRiQr+FpgAaWz3jLzA2HrjqSis3y3GkvNy44wi2SLNQGk4DI8o2IHp3R6W a9q1soMJUe5b6OIn421nfKrIGdLPnOyLJc/dHCGDeBhj8301OuofO2OusQYfp+rVcf9p ZkqHctVz/IN5NxBLP3iRMsjGh6k6kJ394uZ8rFl4n1gdTeYErQuvmVklsuRLvc0fFDgk fcjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=uFVuErhl; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na9-20020a17090b4c0900b00247304b4a27si681277pjb.173.2023.05.19.21.04.46; Fri, 19 May 2023 21:05:01 -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=@infradead.org header.s=bombadil.20210309 header.b=uFVuErhl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbjETDz3 (ORCPT + 99 others); Fri, 19 May 2023 23:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjETDzZ (ORCPT ); Fri, 19 May 2023 23:55:25 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F3A7E3; Fri, 19 May 2023 20:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oL9McTatLzHAnvigXeTVcWUVg0VQVXOaPT42iNyRB/I=; b=uFVuErhl9FJ8po3AK62lX9hvDS oqPSzYD12l6vrFqhWjp8Zp0Tds1+aNcCpz0R2/DYhXeYq5Nqf45/hVBGlYPu0Th5KCrpYeTYJHTu+ rEzVFFIB1bkLogNKU3egCB8886wQgii88jrgrYA21qNeaueL4UFNrq/oVXF6+iqM9890s0Sv2fcZ+ 5YIPlDW6IQpR7Eq9SUhTPkG+CBpJD/SrLX1IgXHoX4VlU1cyNEVtVVEdheuZa21Ew6oLZPZVlmqGX 2X96l2gCZbv5fmOV13NyDPGxDUxRFSEoF+y+couTXvwfpDKDQ1M+rmzaO0Br5FKGiTHfu180VVimF 6AMfAFTw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q0DgF-000bJ1-28; Sat, 20 May 2023 03:54:55 +0000 Date: Fri, 19 May 2023 20:54:55 -0700 From: Christoph Hellwig To: David Howells Cc: Christoph Hellwig , Jens Axboe , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig Subject: Re: [PATCH v20 03/32] splice: Make direct_read_splice() limit to eof where appropriate Message-ID: References: <20230519074047.1739879-1-dhowells@redhat.com> <20230519074047.1739879-4-dhowells@redhat.com> <1742093.1684485814@warthog.procyon.org.uk> <2154518.1684535271@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2154518.1684535271@warthog.procyon.org.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 On Fri, May 19, 2023 at 11:27:51PM +0100, David Howells wrote: > ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, > struct pipe_inode_info *pipe, size_t len, > unsigned int flags) > { > if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes)) > return 0; > if (unlikely(!len)) > return 0; > return filemap_splice_read(in, ppos, pipe, len, flags); > } > > so I wonder if the tests in generic_file_splice_read() can be folded into > vfs_splice_read(), pointers to generic_file_splice_read() be replaced with > pointers to filemap_splice_read() and generic_file_splice_read() just be > removed. > > I suspect we can't quite do this because of the *ppos check - but I wonder if > that's actually necessary since filemap_splice_read() checks against > i_size... or if the check can be moved there if we definitely want to do it. > > Certainly, the zero-length check can be done in vfs_splice_read(). The zero length check makes sense in vfs_splice_read. The ppos check I think makes sense for filemap_splice_read - after all we're dealing with the page cache here, and the page cache needs a working maxbytes and i_size. What callers of filemap_splice_read that don't have the checks do you have in your tree right now and how did you end up with them?