From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C6272DF3E4; Tue, 17 Jun 2025 11:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750161463; cv=none; b=Ir1yBMXJ+OXef6SozmAF3xz12hID8N0kAKIEcsEflVCSiL6Mpj2A+uYI/d2De+WCv374oOOh0+O1gdiV0N/R3uNhBJdavL1fGF/rEWMOzBcz2Zp+sb//7EQ0IcPFdAyi1enlsiQY+ml9F6q/+6klcIjAMup8tj3nW3C8Toqeytw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750161463; c=relaxed/simple; bh=T+hj+yayJhfzqGA9kWHW1UQw8dsCOqK3Vx6p1g+lWhs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AiJLYkF4PZohMHy4NBQW9JVO0SJ9twAuiN+ti1p4uzIuGXPPgS3NKOmbXtsSfWQzmXkhXaEEG72SoNWLTO3r5NEBH4COojxpFZBvfyxkWRVh+jwAzQbVRZE/uloq+60SJricMiJKZCrQ3NiGqTKP2yOQd6ywSDjCNVeWE2cFCtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ANNRMLSM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ANNRMLSM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC2DC4CEE3; Tue, 17 Jun 2025 11:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750161462; bh=T+hj+yayJhfzqGA9kWHW1UQw8dsCOqK3Vx6p1g+lWhs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ANNRMLSMbFJxF0/0JcpxGnRgNC2cM3iQk05j0kIN5dUOf6a+6FhzXEhCV9tljSO6h v2e3uV6HAxpTWa31kRKsnVAXQkLyFD1xYm1QZjMvIFL3ouF6AXeudY39YUcGZrolsh RyM2TZ/EQMyqQ6Y6s4GUWKP0gK9gINzD7L4jwsfBCJ1suak/ya3jB5me4TnYO/YFrF BrbHmvsabgMYM9Mbit9yWCy+NDOo9GjZfXkkWr9NdZCIoi7MIoTDvDFU7neHyJvL+Q sCBOLJVwQyL5L44PlP9UgERzG7VA2X0BjHsxmPcW0plFtm6qxZnaOBFYXof6KFwTQp Bv2/tmMRJtG5w== Date: Tue, 17 Jun 2025 13:57:17 +0200 From: Christian Brauner To: Jan Kara Cc: Lorenzo Stoakes , Andrew Morton , "Liam R . Howlett" , Jens Axboe , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Sterba , David Howells , Marc Dionne , Alexander Viro , Benjamin LaHaise , Miklos Szeredi , Amir Goldstein , Kent Overstreet , "Tigran A . Aivazian" , Kees Cook , Chris Mason , Josef Bacik , Xiubo Li , Ilya Dryomov , Jan Harkes , coda@cs.cmu.edu, Tyler Hicks , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Sandeep Dhavale , Hongbo Li , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Theodore Ts'o , Andreas Dilger , Jaegeuk Kim , OGAWA Hirofumi , Viacheslav Dubeyko , John Paul Adrian Glaubitz , Yangtao Li , Richard Weinberger , Anton Ivanov , Johannes Berg , Mikulas Patocka , David Woodhouse , Dave Kleikamp , Trond Myklebust , Anna Schumaker , Ryusuke Konishi , Konstantin Komarov , Mark Fasheh , Joel Becker , Joseph Qi , Bob Copeland , Mike Marshall , Martin Brandenburg , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Zhihao Cheng , Hans de Goede , Carlos Maiolino , Damien Le Moal , Naohiro Aota , Johannes Thumshirn , Dan Williams , Matthew Wilcox , Vlastimil Babka , Jann Horn , Pedro Falcato , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-aio@kvack.org, linux-unionfs@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, codalist@coda.cs.cmu.edu, ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-um@lists.infradead.org, linux-mtd@lists.infradead.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, ntfs3@lists.linux.dev, ocfs2-devel@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev Subject: Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Message-ID: <20250617-karibus-abgrenzen-e534b9acd4c7@brauner> References: <6nktgdc7ygt6hncfnl33d2jlwvlydspiiklwf6oxiqxxcjhzs2@j6f36ktyv774> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6nktgdc7ygt6hncfnl33d2jlwvlydspiiklwf6oxiqxxcjhzs2@j6f36ktyv774> On Tue, Jun 17, 2025 at 12:28:17PM +0200, Jan Kara wrote: > On Mon 16-06-25 20:33:29, Lorenzo Stoakes wrote: > > Since commit c84bf6dd2b83 ("mm: introduce new .mmap_prepare() file > > callback"), the f_op->mmap() hook has been deprecated in favour of > > f_op->mmap_prepare(). > > > > This callback is invoked in the mmap() logic far earlier, so error handling > > can be performed more safely without complicated and bug-prone state > > unwinding required should an error arise. > > > > This hook also avoids passing a pointer to a not-yet-correctly-established > > VMA avoiding any issues with referencing this data structure. > > > > It rather provides a pointer to the new struct vm_area_desc descriptor type > > which contains all required state and allows easy setting of required > > parameters without any consideration needing to be paid to locking or > > reference counts. > > > > Note that nested filesystems like overlayfs are compatible with an > > .mmap_prepare() callback since commit bb666b7c2707 ("mm: add mmap_prepare() > > compatibility layer for nested file systems"). > > > > In this patch we apply this change to file systems with relatively simple > > mmap() hook logic - exfat, ceph, f2fs, bcachefs, zonefs, btrfs, ocfs2, > > orangefs, nilfs2, romfs, ramfs and aio. > > > > Signed-off-by: Lorenzo Stoakes > > Two small nits below. Otherwise feel free to add: > > Reviewed-by: Jan Kara > > > diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c > > index 60a621b00c65..37522137c380 100644 > > --- a/fs/ceph/addr.c > > +++ b/fs/ceph/addr.c > > @@ -2330,13 +2330,14 @@ static const struct vm_operations_struct ceph_vmops = { > > .page_mkwrite = ceph_page_mkwrite, > > }; > > > > -int ceph_mmap(struct file *file, struct vm_area_struct *vma) > > +int ceph_mmap_prepare(struct vm_area_desc *desc) > > { > > + struct file *file = desc->file; > > struct address_space *mapping = file->f_mapping; > > Pointless local variable here... Agreed, fixed in-tree. > > -static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma) > > +static int exfat_file_mmap_prepare(struct vm_area_desc *desc) > > { > > + struct file *file = desc->file; > > Missing empty line here. Fixed in-tree.