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 8FC8FC636D4 for ; Fri, 17 Feb 2023 08:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbjBQIX1 (ORCPT ); Fri, 17 Feb 2023 03:23:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjBQIX0 (ORCPT ); Fri, 17 Feb 2023 03:23:26 -0500 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 5D6475F24C for ; Fri, 17 Feb 2023 00:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676622157; 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: in-reply-to:in-reply-to:references:references; bh=+rHRyKOcZeIEEhKELSIOc3sAUshwl8ClDrtCaFKbOR0=; b=OLANLPKnw0G/fSHhkjgyODzNPiSn1EAEc37JaV9xF8DKyf0btFrUXzETAOP531vjiQISZL F56EBR05wvH/2sWSC6u7tORUN/0voBA77aGFyBjm4pgjHq/hPZu3yMD97NgF7lzqvD8027 r7/n+J22OZ62M9+IRCqbpIc3lWFW5xI= 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-532-mKHUGlstPr2G68_UGsxnAw-1; Fri, 17 Feb 2023 03:22:30 -0500 X-MC-Unique: mKHUGlstPr2G68_UGsxnAw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 112C885A5A3; Fri, 17 Feb 2023 08:22:30 +0000 (UTC) Received: from T590 (ovpn-8-26.pek2.redhat.com [10.72.8.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 180E6492C3E; Fri, 17 Feb 2023 08:22:19 +0000 (UTC) Date: Fri, 17 Feb 2023 16:22:14 +0800 From: Ming Lei 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 , ming.lei@redhat.com Subject: Re: [PATCH v14 08/17] splice: Do splice read from a file without using ITER_PIPE Message-ID: References: <20230214171330.2722188-1-dhowells@redhat.com> <20230214171330.2722188-9-dhowells@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230214171330.2722188-9-dhowells@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 14, 2023 at 05:13:21PM +0000, David Howells wrote: > Make generic_file_splice_read() use filemap_splice_read() and > direct_splice_read() rather than using an ITER_PIPE and call_read_iter(). > > With this, ITER_PIPE is no longer used. > > Signed-off-by: David Howells > cc: Jens Axboe > cc: Christoph Hellwig > cc: Al Viro > cc: David Hildenbrand > cc: John Hubbard > cc: linux-mm@kvack.org > cc: linux-block@vger.kernel.org > cc: linux-fsdevel@vger.kernel.org > --- > > Notes: > ver #14) > - Split out filemap_splice_read() into a separate patch. > > fs/splice.c | 30 +++++++----------------------- > 1 file changed, 7 insertions(+), 23 deletions(-) > > diff --git a/fs/splice.c b/fs/splice.c > index 4c6332854b63..a93478338cec 100644 > --- a/fs/splice.c > +++ b/fs/splice.c > @@ -391,29 +391,13 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, > struct pipe_inode_info *pipe, size_t len, > unsigned int flags) > { > - struct iov_iter to; > - struct kiocb kiocb; > - int ret; > - > - iov_iter_pipe(&to, ITER_DEST, pipe, len); > - init_sync_kiocb(&kiocb, in); > - kiocb.ki_pos = *ppos; > - ret = call_read_iter(in, &kiocb, &to); > - if (ret > 0) { > - *ppos = kiocb.ki_pos; > - file_accessed(in); > - } else if (ret < 0) { > - /* free what was emitted */ > - pipe_discard_from(pipe, to.start_head); > - /* > - * callers of ->splice_read() expect -EAGAIN on > - * "can't put anything in there", rather than -EFAULT. > - */ > - if (ret == -EFAULT) > - ret = -EAGAIN; > - } > - > - return ret; > + if (unlikely(*ppos >= file_inode(in)->i_sb->s_maxbytes)) > + return 0; > + if (unlikely(!len)) > + return 0; > + if (in->f_flags & O_DIRECT) > + return direct_splice_read(in, ppos, pipe, len, flags); Hello David, I have one question, for dio, pages need to map to userspace memory, but direct_splice_read() just allocates pages and not see when the user mapping is setup, can you give one hint? Thanks, Ming