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 0F524C636D4 for ; Mon, 13 Feb 2023 08:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjBMI2a (ORCPT ); Mon, 13 Feb 2023 03:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjBMI22 (ORCPT ); Mon, 13 Feb 2023 03:28:28 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E919A93EE; Mon, 13 Feb 2023 00:28:25 -0800 (PST) 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=wxlJQMevKqE2XAdU0egXxg4nlul2OuANdQckNSG1zd4=; b=yNP7CW38zlbi1rHHEcCfMou0KT pBdi8juRpMvwvwsEnP/Vq/QjAnZo10E1WpG1u3TH7OSoKL7pzU2oVLEHQM3CSA3zt9Feeenmh3lAi iFfsju82cjg5khya8v2Lfszhk4v7UCJG+LLjjOo+AKw/LwLf1DWVfay/EP55rh1FTTrcOK6QTRjgn RFtVVbLyeVK5Rap9dFg2+X5Br058dC8Yic3ksaaE3Q1dO5rIzAwHcVqK/sZsRa79HQAJZVCIBxRp3 2Fa9GMSUf/i4TNMahqlxJmbm+PiQ5er+7uIK+08KaTkUMgQ0vuWb760ZEXkSx4RdsVMsA0vFJMHPo ts/Z9qPw==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRUC7-00DazA-3L; Mon, 13 Feb 2023 08:28:15 +0000 Date: Mon, 13 Feb 2023 00:28:15 -0800 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 , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , John Hubbard Subject: Re: [PATCH v13 03/12] splice: Do splice read from a buffered file without using ITER_PIPE Message-ID: References: <20230209102954.528942-1-dhowells@redhat.com> <20230209102954.528942-4-dhowells@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230209102954.528942-4-dhowells@redhat.com> 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-kernel@vger.kernel.org > The code is loosely based on filemap_read() and might belong in > mm/filemap.c with that as it needs to use filemap_get_pages(). Yes, I thunk it should go into filemap.c > + while (spliced < size && > + !pipe_full(pipe->head, pipe->tail, pipe->max_usage)) { > + struct pipe_buffer *buf = &pipe->bufs[pipe->head & (pipe->ring_size - 1)]; Can you please facto this calculation, that is also duplicated in patch one into a helper? static inline struct pipe_buffer *pipe_head_buf(struct pipe_inode_info *pipe) { return &pipe->bufs[pipe->head & (pipe->ring_size - 1)]; } > + struct folio_batch fbatch; > + size_t total_spliced = 0, used, npages; > + loff_t isize, end_offset; > + bool writably_mapped; > + int i, error = 0; > + > + struct kiocb iocb = { Why the empty line before this declaration? > + .ki_filp = in, > + .ki_pos = *ppos, > + }; Also why doesn't this use init_sync_kiocb? > if (in->f_flags & O_DIRECT) > return generic_file_direct_splice_read(in, ppos, pipe, len, flags); > + return generic_file_buffered_splice_read(in, ppos, pipe, len, flags); Btw, can we drop the verbose generic_file_ prefix here? generic_file_buffered_splice_read really should be filemap_splice_read and be in filemap.c. generic_file_direct_splice_read I'd just name direct_splice_read.