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 3F308C433EF for ; Mon, 27 Jun 2022 19:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238068AbiF0TRU (ORCPT ); Mon, 27 Jun 2022 15:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237505AbiF0TRS (ORCPT ); Mon, 27 Jun 2022 15:17:18 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8AA0658B for ; Mon, 27 Jun 2022 12:17:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1C08BCE1999 for ; Mon, 27 Jun 2022 19:17:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A52F4C3411D; Mon, 27 Jun 2022 19:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656357432; bh=tFetw5NCVLOiu/AWHrIJlhVVxr2cmD5N31YmOV3PpTM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AGed8b1hdAqqS6EIjtSzDJOQ/MPLHNcCzIrxD4jKw+4ca5v9z/or4ot0PEcVFhMvV cAuSKDPHJC1XAxzT09tCHBgPdqsTvEziUaajt5JgLvrhugFqk84PRSUFFz09oUAqcQ HeVtsOFeYBh/z/qs1e6YzhePO9SbYe1g6NLNhjlJLxCdpY0tKfsnsISfvT0gg88vmI AHnSk1BNSDw83NNrf2k6sfFxm3OL/5x/7Eaaz5kKiYX5vIIqaXoXZNxFNEeJusEmZE ScBLVLeQvb1tUQilUZ/akJYZZKN5Y3suJZw030fJBKABsXRPn998A/WNxQShXYjsUj K51BfSXBtjykQ== Message-ID: <2e5f03a41758b2bfd6e9577b9f7bf46dc0fa2c55.camel@kernel.org> Subject: Re: [PATCH 13/44] splice: stop abusing iov_iter_advance() to flush a pipe From: Jeff Layton To: Al Viro , linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Jens Axboe , Christoph Hellwig , Matthew Wilcox , David Howells , Dominique Martinet , Christian Brauner Date: Mon, 27 Jun 2022 15:17:10 -0400 In-Reply-To: <20220622041552.737754-13-viro@zeniv.linux.org.uk> References: <20220622041552.737754-1-viro@zeniv.linux.org.uk> <20220622041552.737754-13-viro@zeniv.linux.org.uk> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, 2022-06-22 at 05:15 +0100, Al Viro wrote: > Use pipe_discard_from() explicitly in generic_file_read_iter(); don't bot= her > with rather non-obvious use of iov_iter_advance() in there. >=20 > Signed-off-by: Al Viro > --- > fs/splice.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) >=20 > diff --git a/fs/splice.c b/fs/splice.c > index 047b79db8eb5..6645b30ec990 100644 > --- a/fs/splice.c > +++ b/fs/splice.c > @@ -301,11 +301,9 @@ ssize_t generic_file_splice_read(struct file *in, lo= ff_t *ppos, > { > struct iov_iter to; > struct kiocb kiocb; > - unsigned int i_head; > int ret; > =20 > iov_iter_pipe(&to, READ, pipe, len); > - i_head =3D to.head; > init_sync_kiocb(&kiocb, in); > kiocb.ki_pos =3D *ppos; > ret =3D call_read_iter(in, &kiocb, &to); > @@ -313,9 +311,8 @@ ssize_t generic_file_splice_read(struct file *in, lof= f_t *ppos, > *ppos =3D kiocb.ki_pos; > file_accessed(in); > } else if (ret < 0) { > - to.head =3D i_head; > - to.iov_offset =3D 0; > - iov_iter_advance(&to, 0); /* to free what was emitted */ > + /* 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. Reviewed-by: Jeff Layton