Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp572721rwd; Sat, 20 May 2023 02:58:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4KV25qmC5/bWmVJst2vDXJKEOMtICsoLfvj3IpZkyR40Gqn2crY9in/ZEWAlfM2oLMnE8/ X-Received: by 2002:a05:6a00:1a15:b0:64d:88b:a342 with SMTP id g21-20020a056a001a1500b0064d088ba342mr5713356pfv.30.1684576683727; Sat, 20 May 2023 02:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684576683; cv=none; d=google.com; s=arc-20160816; b=gi3jPTU4yRAtfms88f92pw6RDMKnWYntUvodZ2vZAgGbt7XP0l8OhFgVACz9vhTEn+ QyUpoSCeTkGaATBzHY5esYpMdIVREnahttF33leghkJ6s80tnvkPn5kd0AWohYOZLM3o WvWHtYMjQuLQLSJrMu9SW241rqsPCqJXdum4nuqdJHQLJ4EYDHNO2DH7JM2+VQakk0OU imjwtkn+unX0vF2SAAIyEVWBg/RjIfJma6EWKfUYAG46uwEd5K2ovY9zh9ucyz8Vc9T+ TYz1M0CJ8H4RidQu2ipG6M1vBJk07i+awrhPhKjsI8lQ4RC573ZWh2ao+dXUhOCrYibL EX3g== 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=C+0tZreXiQlswzBbgUqqZMzglcH1sO6MGoDTEJVa7zs=; b=ifqEnCX9qN5uLuQb643OL0/L02xUUJZI9MfChR4ZOmso8bX8PopAmz5eIe8K29yN+q L3LUu3ZG8MFuNqBEdVR+O7V6kj6wV+VmsGnyN12P0jKXvi0Ve5Zin6mmc4of677HcEUw +u5fbdUWEvKqX0WciT2V7GuUP4z8NRUu+MXCSX5ytznQGy9EDmODrQQbdi6kE/neTTDp f5nyBIAoBuKnL3G5nYgYKiIGTOsbCI1amfeEgG3JqHTvAO0yyMHOnswvyLsWzPqCbfFs 8MYyzveMeXLIocQTo9G66c9ONll17r4IfGNAh6zLpbt9SRrkBkIqkzz2qdOu3Hqtpu6E SvYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pZFm8NQY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a627b12000000b00643a695e976si1261600pfc.291.2023.05.20.02.57.50; Sat, 20 May 2023 02:58:03 -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=@kernel.org header.s=k20201202 header.b=pZFm8NQY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231368AbjETJrc (ORCPT + 99 others); Sat, 20 May 2023 05:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjETJrb (ORCPT ); Sat, 20 May 2023 05:47:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4F01BD; Sat, 20 May 2023 02:47:30 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9333260B6C; Sat, 20 May 2023 09:47:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 251B0C433EF; Sat, 20 May 2023 09:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684576048; bh=tpbo4BqtQNV64ZRx85M71kPc027/14n1Atl6YMev6Nw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pZFm8NQY+xZm8guWK+z/3dddQXvn4pHCJ9Yl/pAvhhPb/EOs9yGAznOr1NN3KcI9n kroj0W5v9/EVnsYLKAeHtnt4zR2V3URnHJjks5ik5JzTLT6IwNd/2zXSybyjZPp/6F gh7yL0T4hRTcx3p/ulTt1p4F9dEwLi5hRS6qqsgRnaR0gQvcIfqNGOT9iLkaBCqd+v 94t+vqHVE64VLRbG98KcN4+B/6xeVB09BQ77glqqasMKN3neUwrTcMiIs8ZlFWQuzC 1nckliMlCLM6KNkTmGG3sn3xggbthm2/sZZBMairxZT0KER7Q49aTk0m+oHrTdxzC2 W+IbQC53gqZmg== Date: Sat, 20 May 2023 11:47:20 +0200 From: Christian Brauner To: David Howells Cc: Jens Axboe , Al Viro , Christoph Hellwig , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , John Hubbard , Miklos Szeredi , linux-unionfs@vger.kernel.org, Amir Goldstein Subject: Re: [PATCH v21 10/30] overlayfs: Implement splice-read Message-ID: <20230520-zeitplan-erdig-b97a98a72261@brauner> References: <20230520000049.2226926-1-dhowells@redhat.com> <20230520000049.2226926-11-dhowells@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230520000049.2226926-11-dhowells@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 [Cc Amir as well] On Sat, May 20, 2023 at 01:00:29AM +0100, David Howells wrote: > Implement splice-read for overlayfs by passing the request down a layer > rather than going through generic_file_splice_read() which is going to be > changed to assume that ->read_folio() is present on buffered files. > > Signed-off-by: David Howells > cc: Christoph Hellwig > cc: Jens Axboe > cc: Al Viro > cc: John Hubbard > cc: David Hildenbrand > cc: Matthew Wilcox > cc: Miklos Szeredi > cc: linux-unionfs@vger.kernel.org > cc: linux-block@vger.kernel.org > cc: linux-fsdevel@vger.kernel.org > cc: linux-mm@kvack.org > --- Acked-by: Christian Brauner > > Notes: > ver #17) > - Use vfs_splice_read() helper rather than open-coding checks. > > ver #15) > - Remove redundant FMODE_CAN_ODIRECT check on real file. > - Do rw_verify_area() on the real file, not the overlay file. > - Fix a file leak. > > fs/overlayfs/file.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c > index 7c04f033aadd..86197882ff35 100644 > --- a/fs/overlayfs/file.c > +++ b/fs/overlayfs/file.c > @@ -419,6 +419,27 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) > return ret; > } > > +static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, > + struct pipe_inode_info *pipe, size_t len, > + unsigned int flags) > +{ > + const struct cred *old_cred; > + struct fd real; > + ssize_t ret; > + > + ret = ovl_real_fdget(in, &real); > + if (ret) > + return ret; > + > + old_cred = ovl_override_creds(file_inode(in)->i_sb); > + ret = vfs_splice_read(real.file, ppos, pipe, len, flags); > + revert_creds(old_cred); > + ovl_file_accessed(in); > + > + fdput(real); > + return ret; > +} > + > /* > * Calling iter_file_splice_write() directly from overlay's f_op may deadlock > * due to lock order inversion between pipe->mutex in iter_file_splice_write() > @@ -695,7 +716,7 @@ const struct file_operations ovl_file_operations = { > .fallocate = ovl_fallocate, > .fadvise = ovl_fadvise, > .flush = ovl_flush, > - .splice_read = generic_file_splice_read, > + .splice_read = ovl_splice_read, > .splice_write = ovl_splice_write, > > .copy_file_range = ovl_copy_file_range, >