From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05B24C7EE29 for ; Sat, 20 May 2023 03:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbjETDz1 (ORCPT ); Fri, 19 May 2023 23:55:27 -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 Precedence: bulk List-ID: X-Mailing-List: linux-block@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?