Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2138909rwd; Fri, 19 May 2023 01:17:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Es5PhkJyJERQv0KFKenAJDbbNxuxEmRB61Eyyi/9SI5Mh0z5pQTtIo2yyTQhCjpOnvkxS X-Received: by 2002:a17:903:22cd:b0:1a6:71b1:a0b9 with SMTP id y13-20020a17090322cd00b001a671b1a0b9mr2057344plg.47.1684484274904; Fri, 19 May 2023 01:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684484274; cv=none; d=google.com; s=arc-20160816; b=CGdcgF1cuwVtmkn/hDGNSGzvAVDuskb9aa2/wIkKQaorv+Zq9AdrzAfM7J63sJceNV HIq8XIxR3NrlfC4LADvSCgSkORAHb4jSthMzekPDDo86WeJvRuKoFyYtyNdbu+W/f4OO /cWqJIIN9Ylr+4/4xWcocsoKpHwA86P8qUDltO7PP8MCBzYMXTmjidfMvh1Dt1uLB/+3 VbRAL0qob2TgWUulvI8lb2XA1mwjSHidoveneL+9zr4EC8riIfwG3zpdq8nN48tHhhbX j0HrIkxU08pY8lymWXKMyud8JDhSVke81VpS3y9Ohg7QkIhUPW+aOCOjTVV9DCUZHd29 qZJw== 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=rN0X/XLgI1H9n9vRzMaxHiNIPrJVP5jdj7ESUMoVA4c=; b=D98Uh74oI5CQeI+CxNSahGrcZ7urbnycT22uF+2LHzk/V07fGPxXy/YiL0OQYvcZ5M 1PjOqgKY5m/ZnmBaFnsTA3eQDGtShTD3cdfswBrD6t2o8C2PIbJr1Y7NuCizsCLRL7rf OsH1O54dr7Jnnxbjq/RkwLW7VHV0GoCvVQSi3UV6dYVpv2dJg48gjhRdCBypfsYFd+hE V5c+TPCDjy74zQ4wxHJbvJlskDB9AL4A2P8uN4JwSTL31ZU8lg8pjih8oj84JfJ1muGH tPTls86gvRhP0oCky0hp9YLJ/nrwxgoMUh7OR7K+PVnYs33g8GIvcZtnQSWaPm8BeVQH 2QPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=3hkfsW6g; 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 12-20020a170902c20c00b001a6bb44db86si3156629pll.226.2023.05.19.01.17.39; Fri, 19 May 2023 01:17:54 -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=3hkfsW6g; 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 S229954AbjESIJd (ORCPT + 99 others); Fri, 19 May 2023 04:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjESIJc (ORCPT ); Fri, 19 May 2023 04:09:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8559C98; Fri, 19 May 2023 01:09:31 -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=rN0X/XLgI1H9n9vRzMaxHiNIPrJVP5jdj7ESUMoVA4c=; b=3hkfsW6g5HJxxVvstAtx/nMk9k S37soTRQSDBNY5Q4G5cPwMXY4bgc4us5+JjZcJG7uw/6MmP7PkyGvXkqONdegb+V/pAkJ/7Y5sLDa Ga3jgFmYcGMC8zy9e6p8PoCsVwquDIJT/bCvUNXxBJ+Y1s3YEBP66qv5uYClVIizRRcxxiKIv8G7n IycPJ6ii3xtOcd0Tsx/K0+BTGkPB6BYhH8YB3gc5M2sFWr/S879sO0eHIvyEW/snkhfXI4BBUWzIE TG+EUq3Q4VT1cWiJUW42c2abfWbOxmnEqwUzoJFo/VUc3nSaTAk6mtAnNBaQtMhT3lup4wCRMQISY BFYggVOg==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pzvAu-00FTRH-1c; Fri, 19 May 2023 08:09:20 +0000 Date: Fri, 19 May 2023 01:09:20 -0700 From: Christoph Hellwig To: David Howells Cc: Jens Axboe , Al Viro , Christoph Hellwig , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230519074047.1739879-4-dhowells@redhat.com> 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 08:40:18AM +0100, David Howells wrote: > Make direct_read_splice() limit the read to the end of the file for regular > files and block devices, thereby reducing the amount of allocation it will > do in such a case. > > This means that the blockdev code doesn't require any special handling as > filemap_read_splice() also limits to i_size. I'm really not sure if this is a good idea. Right now direct_read_splice (which also appears a little misnamed) really is a splice by calling ->read_iter helper. I we don't do any of this validtion we can just call it directly from splice.c instead of calling into ->splice_read for direct I/O and DAX and remove a ton of boilerplate code. How often do we even call into splice beyond i_size and for how much? > + if (S_ISREG(file_inode(in)->i_mode) || > + S_ISBLK(file_inode(in)->i_mode)) { Btw, having these kinds of checks in supposedly generic code is always a marked for a bit of a layering problem.