* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] <cover.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-16 19:56 ` Kent Overstreet
[not found] ` <08db85970d89b17a995d2cffae96fb4cc462377f.1750099179.git.lorenzo.stoakes@oracle.com>
` (13 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Kent Overstreet @ 2025-06-16 19:56 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Andrew Morton, linux-block, linux-kernel, intel-gfx, dri-devel,
v9fs, linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
Mailserver is rejecting with "too many recipients" - aieeee
On Mon, Jun 16, 2025 at 08:33:19PM +0100, Lorenzo Stoakes wrote:
> REVIEWER'S NOTES
> ================
>
> I am basing this on the mm-new branch in Andrew's tree, so let me know if I
> should rebase anything here. Given the mm bits touched I did think perhaps
> we should take it through the mm tree, however it may be more sensible to
> take it through an fs tree - let me know!
>
> Apologies for the noise/churn, but there are some prerequisite steps here
> that inform an ordering - "fs: consistently use file_has_valid_mmap_hooks()
> helper" being especially critical, and so I put the bulk of the work in the
> same series.
>
> Let me know if there's anything I can do to make life easier here.
This seems to be more of an mm thing than a filesystem thing? I don't
see any code changes on the filesystem side from a quick scan, just
renaming?
Are there any behavioural changes for the filesystem to be aware of?
How's it been tested, any considerations there?
If this is as simple as it looks, ack from me (and if it is that simply,
why so many recipients?).
If there are _any_ behavioural changes on the mm side that might
interact with the filesystem in funny ways, please make sure the whole
fstests suite has been run.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 09/10] fs: convert most other generic_file_*mmap() users to .mmap_prepare()
[not found] ` <08db85970d89b17a995d2cffae96fb4cc462377f.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 10:23 ` Jan Kara
2025-06-17 11:54 ` Christian Brauner
0 siblings, 1 reply; 21+ messages in thread
From: Jan Kara @ 2025-06-17 10:23 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On Mon 16-06-25 20:33:28, Lorenzo Stoakes wrote:
> Update nearly all generic_file_mmap() and generic_file_readonly_mmap()
> callers to use generic_file_mmap_prepare() and
> generic_file_readonly_mmap_prepare() respectively.
>
> We update blkdev, 9p, afs, erofs, ext2, nfs, ntfs3, smb, ubifs and vboxsf
> file systems this way.
>
> Remaining users we cannot yet update are ecryptfs, fuse and cramfs. The
> former two are nested file systems that must support any underlying file
> ssytem, and cramfs inserts a mixed mapping which currently requires a VMA.
>
> Once all file systems have been converted to mmap_prepare(), we can then
> update nested file systems.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Overall the patch looks good. Just a couple of notes regarding pointless
local variable being created...
> ---
> block/fops.c | 9 +++++----
> fs/9p/vfs_file.c | 11 ++++++-----
> fs/afs/file.c | 11 ++++++-----
> fs/erofs/data.c | 16 +++++++++-------
> fs/ext2/file.c | 12 +++++++-----
> fs/nfs/file.c | 13 +++++++------
> fs/nfs/internal.h | 2 +-
> fs/nfs/nfs4file.c | 2 +-
> fs/ntfs3/file.c | 15 ++++++++-------
> fs/smb/client/cifsfs.c | 12 ++++++------
> fs/smb/client/cifsfs.h | 4 ++--
> fs/smb/client/file.c | 14 ++++++++------
> fs/ubifs/file.c | 8 ++++----
> fs/vboxsf/file.c | 8 ++++----
> 14 files changed, 74 insertions(+), 63 deletions(-)
>
> diff --git a/block/fops.c b/block/fops.c
> index 1309861d4c2c..5a0ebc81e489 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -911,14 +911,15 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
> return error;
> }
>
> -static int blkdev_mmap(struct file *file, struct vm_area_struct *vma)
> +static int blkdev_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> struct inode *bd_inode = bdev_file_inode(file);
I guess no need to create 'file' variable here since it has only one use in
the line above...
>
> if (bdev_read_only(I_BDEV(bd_inode)))
> - return generic_file_readonly_mmap(file, vma);
> + return generic_file_readonly_mmap_prepare(desc);
>
> - return generic_file_mmap(file, vma);
> + return generic_file_mmap_prepare(desc);
> }
>
> const struct file_operations def_blk_fops = {
...
> @@ -492,16 +492,17 @@ static void afs_drop_open_mmap(struct afs_vnode *vnode)
> /*
> * Handle setting up a memory mapping on an AFS file.
> */
> -static int afs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int afs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
Same comment about pointless local variable here as well.
> int ret;
>
> afs_add_open_mmap(vnode);
>
> - ret = generic_file_mmap(file, vma);
> + ret = generic_file_mmap_prepare(desc);
> if (ret == 0)
> - vma->vm_ops = &afs_vm_ops;
> + desc->vm_ops = &afs_vm_ops;
> else
> afs_drop_open_mmap(vnode);
> return ret;
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 6a329c329f43..52dfd1a44c43 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -409,20 +409,22 @@ static const struct vm_operations_struct erofs_dax_vm_ops = {
> .huge_fault = erofs_dax_huge_fault,
> };
>
> -static int erofs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> +
> if (!IS_DAX(file_inode(file)))
And here...
> - return generic_file_readonly_mmap(file, vma);
> + return generic_file_readonly_mmap_prepare(desc);
>
> - if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
> + if ((desc->vm_flags & VM_SHARED) && (desc->vm_flags & VM_MAYWRITE))
> return -EINVAL;
>
> - vma->vm_ops = &erofs_dax_vm_ops;
> - vm_flags_set(vma, VM_HUGEPAGE);
> + desc->vm_ops = &erofs_dax_vm_ops;
> + desc->vm_flags |= VM_HUGEPAGE;
> return 0;
> }
...
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 9835672267d2..2ed5173cfa73 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -2995,8 +2995,9 @@ static const struct vm_operations_struct cifs_file_vm_ops = {
> .page_mkwrite = cifs_page_mkwrite,
> };
>
> -int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
> +int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> int xid, rc = 0;
> struct inode *inode = file_inode(file);
Again pointless local variable 'file' here.
>
> @@ -3005,16 +3006,17 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
> if (!CIFS_CACHE_READ(CIFS_I(inode)))
> rc = cifs_zap_mapping(inode);
> if (!rc)
> - rc = generic_file_mmap(file, vma);
> + rc = generic_file_mmap_prepare(desc);
> if (!rc)
> - vma->vm_ops = &cifs_file_vm_ops;
> + desc->vm_ops = &cifs_file_vm_ops;
>
> free_xid(xid);
> return rc;
> }
>
> -int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +int cifs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> int rc, xid;
And here (the only use is in cifs_revalidate_file(file)).
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
[not found] ` <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 10:28 ` Jan Kara
2025-06-17 11:57 ` Christian Brauner
2025-06-18 17:06 ` David Sterba
2025-06-19 17:47 ` Ryusuke Konishi
2 siblings, 1 reply; 21+ messages in thread
From: Jan Kara @ 2025-06-17 10:28 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
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 <lorenzo.stoakes@oracle.com>
Two small nits below. Otherwise feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
> 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...
>
> if (!mapping->a_ops->read_folio)
> return -ENOEXEC;
> - vma->vm_ops = &ceph_vmops;
> + desc->vm_ops = &ceph_vmops;
> return 0;
> }
>
...
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index 841a5b18e3df..d63213c8a823 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -683,13 +683,14 @@ static const struct vm_operations_struct exfat_file_vm_ops = {
> .page_mkwrite = exfat_page_mkwrite,
> };
>
> -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.
> if (unlikely(exfat_forced_shutdown(file_inode(file)->i_sb)))
> return -EIO;
>
> file_accessed(file);
> - vma->vm_ops = &exfat_file_vm_ops;
> + desc->vm_ops = &exfat_file_vm_ops;
> return 0;
> }
>
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] ` <20250616161111.74e10321c4c421674f78d689@linux-foundation.org>
@ 2025-06-17 11:31 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:31 UTC (permalink / raw)
To: Andrew Morton
Cc: Lorenzo Stoakes, 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, Jan Kara,
Benjamin LaHaise, Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Mon, Jun 16, 2025 at 04:11:11PM -0700, Andrew Morton wrote:
> On Mon, 16 Jun 2025 20:33:19 +0100 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>
> > I am basing this on the mm-new branch in Andrew's tree, so let me know if I
> > should rebase anything here. Given the mm bits touched I did think perhaps
> > we should take it through the mm tree, however it may be more sensible to
> > take it through an fs tree - let me know!
>
> It's more fs/ than mm/ purely from a footprint point of view. But
> there any expectation that there will be additional patches which build
> on this?
>
> I'll scoop it into mm-new for now, see what happens.
I'm going to carry this in the vfs-6.17.mmap_prepare branch after fixing
up the various minor issues spotted in the series.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 04/10] fs/dax: make it possible to check dev dax support without a VMA
[not found] ` <aFB-Do9FE6H9SsGY@casper.infradead.org>
@ 2025-06-17 11:43 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:43 UTC (permalink / raw)
To: Matthew Wilcox
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,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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, Vlastimil Babka,
Jann Horn, Pedro Falcato, linux-block, linux-kernel, intel-gfx,
dri-devel, v9fs, linux-fsdevel, linux-afs, linux-aio,
linux-unionfs, linux-bcachefs, linux-mm, linux-btrfs, ceph-devel,
codalist, ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel,
linux-um, linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
ntfs3, ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Mon, Jun 16, 2025 at 09:26:54PM +0100, Matthew Wilcox wrote:
> On Mon, Jun 16, 2025 at 08:33:23PM +0100, Lorenzo Stoakes wrote:
> > fs/ext4/file.c | 2 +-
> > fs/xfs/xfs_file.c | 3 ++-
>
> Both of these already have the inode from the file ...
>
> > +static inline bool daxdev_mapping_supported(vm_flags_t vm_flags,
> > + struct file *file,
> > + struct dax_device *dax_dev)
> > {
> > - if (!(vma->vm_flags & VM_SYNC))
> > + if (!(vm_flags & VM_SYNC))
> > return true;
> > - if (!IS_DAX(file_inode(vma->vm_file)))
> > + if (!IS_DAX(file_inode(file)))
> > return false;
> > return dax_synchronous(dax_dev);
>
> ... and the only thing this function uses from the file is the inode.
> So maybe pass in the inode rather than the file?
Agreed. I've converted this to take const struct inode *.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 06/10] fs/xfs: transition from deprecated .mmap hook to .mmap_prepare
[not found] ` <aFD4M48RMZB0Hj-f@infradead.org>
@ 2025-06-17 11:45 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:45 UTC (permalink / raw)
To: Christoph Hellwig
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,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On Mon, Jun 16, 2025 at 10:08:03PM -0700, Christoph Hellwig wrote:
> On Mon, Jun 16, 2025 at 08:33:25PM +0100, Lorenzo Stoakes wrote:
> > STATIC int
> > -xfs_file_mmap(
> > - struct file *file,
> > - struct vm_area_struct *vma)
> > +xfs_file_mmap_prepare(
> > + struct vm_area_desc *desc)
>
> Please stick to the existing alignment for the declarations.
>
> Otherwise this looks good.
Fixed in-tree.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 03/10] fs: consistently use file_has_valid_mmap_hooks() helper
[not found] ` <kzp4cei5qq6gbtzzng7hmqj5avzblopfzzrks4e2gahcdvr7ro@cwziankavxw4>
@ 2025-06-17 11:48 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:48 UTC (permalink / raw)
To: Jan Kara
Cc: Lorenzo Stoakes, Christoph Hellwig, 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,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On Tue, Jun 17, 2025 at 12:08:13PM +0200, Jan Kara wrote:
> On Tue 17-06-25 06:25:34, Lorenzo Stoakes wrote:
> > On Mon, Jun 16, 2025 at 10:11:28PM -0700, Christoph Hellwig wrote:
> > > On Mon, Jun 16, 2025 at 08:33:22PM +0100, 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().
> > > >
> > > > Additionally, commit bb666b7c2707 ("mm: add mmap_prepare() compatibility
> > > > layer for nested file systems") permits the use of the .mmap_prepare() hook
> > > > even in nested filesystems like overlayfs.
> > > >
> > > > There are a number of places where we check only for f_op->mmap - this is
> > > > incorrect now mmap_prepare exists, so update all of these to use the
> > > > general helper file_has_valid_mmap_hooks().
> > > >
> > > > Most notably, this updates the elf logic to allow for the ability to
> > > > execute binaries on filesystems which have the .mmap_prepare hook, but
> > > > additionally we update nested filesystems.
> > >
> > > Can you please give the function a better name before spreading it?
> > > file operations aren't hooks by any classic definition.
> > >
> >
> > can_mmap_file()?
>
> I like this name more as well :). With this patch looks good to me. Again a
Fixed in-tree.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 09/10] fs: convert most other generic_file_*mmap() users to .mmap_prepare()
2025-06-17 10:23 ` [PATCH 09/10] fs: convert most other generic_file_*mmap() users to .mmap_prepare() Jan Kara
@ 2025-06-17 11:54 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:54 UTC (permalink / raw)
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, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Tue, Jun 17, 2025 at 12:23:41PM +0200, Jan Kara wrote:
> On Mon 16-06-25 20:33:28, Lorenzo Stoakes wrote:
> > Update nearly all generic_file_mmap() and generic_file_readonly_mmap()
> > callers to use generic_file_mmap_prepare() and
> > generic_file_readonly_mmap_prepare() respectively.
> >
> > We update blkdev, 9p, afs, erofs, ext2, nfs, ntfs3, smb, ubifs and vboxsf
> > file systems this way.
> >
> > Remaining users we cannot yet update are ecryptfs, fuse and cramfs. The
> > former two are nested file systems that must support any underlying file
> > ssytem, and cramfs inserts a mixed mapping which currently requires a VMA.
> >
> > Once all file systems have been converted to mmap_prepare(), we can then
> > update nested file systems.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> Overall the patch looks good. Just a couple of notes regarding pointless
> local variable being created...
>
> > ---
> > block/fops.c | 9 +++++----
> > fs/9p/vfs_file.c | 11 ++++++-----
> > fs/afs/file.c | 11 ++++++-----
> > fs/erofs/data.c | 16 +++++++++-------
> > fs/ext2/file.c | 12 +++++++-----
> > fs/nfs/file.c | 13 +++++++------
> > fs/nfs/internal.h | 2 +-
> > fs/nfs/nfs4file.c | 2 +-
> > fs/ntfs3/file.c | 15 ++++++++-------
> > fs/smb/client/cifsfs.c | 12 ++++++------
> > fs/smb/client/cifsfs.h | 4 ++--
> > fs/smb/client/file.c | 14 ++++++++------
> > fs/ubifs/file.c | 8 ++++----
> > fs/vboxsf/file.c | 8 ++++----
> > 14 files changed, 74 insertions(+), 63 deletions(-)
> >
> > diff --git a/block/fops.c b/block/fops.c
> > index 1309861d4c2c..5a0ebc81e489 100644
> > --- a/block/fops.c
> > +++ b/block/fops.c
> > @@ -911,14 +911,15 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
> > return error;
> > }
> >
> > -static int blkdev_mmap(struct file *file, struct vm_area_struct *vma)
> > +static int blkdev_mmap_prepare(struct vm_area_desc *desc)
> > {
> > + struct file *file = desc->file;
> > struct inode *bd_inode = bdev_file_inode(file);
>
> I guess no need to create 'file' variable here since it has only one use in
> the line above...
Agreed, fixed in-tree.
> > -static int afs_file_mmap(struct file *file, struct vm_area_struct *vma)
> > +static int afs_file_mmap_prepare(struct vm_area_desc *desc)
> > {
> > + struct file *file = desc->file;
> > struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
>
> Same comment about pointless local variable here as well.
Same.
> > -static int erofs_file_mmap(struct file *file, struct vm_area_struct *vma)
> > +static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
> > {
> > + struct file *file = desc->file;
> > +
> > if (!IS_DAX(file_inode(file)))
>
> And here...
Same.
> > -int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
> > +int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc)
> > {
> > + struct file *file = desc->file;
> > int xid, rc = 0;
> > struct inode *inode = file_inode(file);
>
> Again pointless local variable 'file' here.
Same.
> > -int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
> > +int cifs_file_mmap_prepare(struct vm_area_desc *desc)
> > {
> > + struct file *file = desc->file;
> > int rc, xid;
>
> And here (the only use is in cifs_revalidate_file(file)).
Same.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
2025-06-17 10:28 ` [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Jan Kara
@ 2025-06-17 11:57 ` Christian Brauner
0 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:57 UTC (permalink / raw)
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, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
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 <lorenzo.stoakes@oracle.com>
>
> Two small nits below. Otherwise feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> > 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.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] <cover.1750099179.git.lorenzo.stoakes@oracle.com>
` (5 preceding siblings ...)
[not found] ` <b68145b609532e62bab603dd9686faa6562046ec.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 11:58 ` Christian Brauner
[not found] ` <20250616204149.GK1880847@ZenIV>
` (7 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Christian Brauner @ 2025-06-17 11:58 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Christian Brauner, 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, Jan Kara,
Benjamin LaHaise, Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm, Andrew Morton
On Mon, 16 Jun 2025 20:33:19 +0100, Lorenzo Stoakes wrote:
> REVIEWER'S NOTES
> ================
>
> I am basing this on the mm-new branch in Andrew's tree, so let me know if I
> should rebase anything here. Given the mm bits touched I did think perhaps
> we should take it through the mm tree, however it may be more sensible to
> take it through an fs tree - let me know!
>
> [...]
This looks good. I fixed up the minor review comments.
Looking forward to further cleanups in this area.
---
Applied to the vfs-6.17.mmap_prepare branch of the vfs/vfs.git tree.
Patches in the vfs-6.17.mmap_prepare branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.17.mmap_prepare
[01/10] mm: rename call_mmap/mmap_prepare to vfs_mmap/mmap_prepare
https://git.kernel.org/vfs/vfs/c/20ca475d9860
[02/10] mm/nommu: use file_has_valid_mmap_hooks() helper
https://git.kernel.org/vfs/vfs/c/c6900f227f89
[03/10] fs: consistently use file_has_valid_mmap_hooks() helper
https://git.kernel.org/vfs/vfs/c/b013ed403197
[04/10] fs/dax: make it possible to check dev dax support without a VMA
https://git.kernel.org/vfs/vfs/c/0335f6afd348
[05/10] fs/ext4: transition from deprecated .mmap hook to .mmap_prepare
https://git.kernel.org/vfs/vfs/c/8c90ae8fe5e3
[06/10] fs/xfs: transition from deprecated .mmap hook to .mmap_prepare
https://git.kernel.org/vfs/vfs/c/6528d29b46d8
[07/10] mm/filemap: introduce generic_file_*_mmap_prepare() helpers
https://git.kernel.org/vfs/vfs/c/5b44297bcfa4
[08/10] fs: convert simple use of generic_file_*_mmap() to .mmap_prepare()
https://git.kernel.org/vfs/vfs/c/951ea2f4844c
[09/10] fs: convert most other generic_file_*mmap() users to .mmap_prepare()
https://git.kernel.org/vfs/vfs/c/a5ee9a82981d
[10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
https://git.kernel.org/vfs/vfs/c/a1e5b36c4034
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] ` <20250616204149.GK1880847@ZenIV>
@ 2025-06-17 13:45 ` Jeff Layton
2025-06-17 13:46 ` Lorenzo Stoakes
0 siblings, 1 reply; 21+ messages in thread
From: Jeff Layton @ 2025-06-17 13:45 UTC (permalink / raw)
To: Al Viro, Lorenzo Stoakes
Cc: 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, Christian Brauner, Jan Kara,
Benjamin LaHaise, Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Mon, 2025-06-16 at 21:41 +0100, Al Viro wrote:
> On Mon, Jun 16, 2025 at 08:33:19PM +0100, Lorenzo Stoakes wrote:
> > REVIEWER'S NOTES
> > ================
> >
> > I am basing this on the mm-new branch in Andrew's tree, so let me know if I
> > should rebase anything here. Given the mm bits touched I did think perhaps
> > we should take it through the mm tree, however it may be more sensible to
> > take it through an fs tree - let me know!
> >
> > Apologies for the noise/churn, but there are some prerequisite steps here
> > that inform an ordering - "fs: consistently use file_has_valid_mmap_hooks()
> > helper" being especially critical, and so I put the bulk of the work in the
> > same series.
> >
> > Let me know if there's anything I can do to make life easier here.
>
> Documentation/filesystems/porting.rst?
Also, an entry for ->mmap_prepare in Documentation/filesystems/vfs.rst
would be good.
I went there first to understand what the requirements of mmap_prepare
are, but there is nothing.
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
2025-06-17 13:45 ` Jeff Layton
@ 2025-06-17 13:46 ` Lorenzo Stoakes
0 siblings, 0 replies; 21+ messages in thread
From: Lorenzo Stoakes @ 2025-06-17 13:46 UTC (permalink / raw)
To: Jeff Layton
Cc: Al Viro, 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, Christian Brauner, Jan Kara,
Benjamin LaHaise, Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Tue, Jun 17, 2025 at 09:45:32AM -0400, Jeff Layton wrote:
> On Mon, 2025-06-16 at 21:41 +0100, Al Viro wrote:
> > On Mon, Jun 16, 2025 at 08:33:19PM +0100, Lorenzo Stoakes wrote:
> > > REVIEWER'S NOTES
> > > ================
> > >
> > > I am basing this on the mm-new branch in Andrew's tree, so let me know if I
> > > should rebase anything here. Given the mm bits touched I did think perhaps
> > > we should take it through the mm tree, however it may be more sensible to
> > > take it through an fs tree - let me know!
> > >
> > > Apologies for the noise/churn, but there are some prerequisite steps here
> > > that inform an ordering - "fs: consistently use file_has_valid_mmap_hooks()
> > > helper" being especially critical, and so I put the bulk of the work in the
> > > same series.
> > >
> > > Let me know if there's anything I can do to make life easier here.
> >
> > Documentation/filesystems/porting.rst?
>
> Also, an entry for ->mmap_prepare in Documentation/filesystems/vfs.rst
> would be good.
>
> I went there first to understand what the requirements of mmap_prepare
> are, but there is nothing.
Ack, on it.
> --
> Jeff Layton <jlayton@kernel.org>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] <cover.1750099179.git.lorenzo.stoakes@oracle.com>
` (7 preceding siblings ...)
[not found] ` <20250616204149.GK1880847@ZenIV>
@ 2025-06-17 14:05 ` David Howells
2025-06-17 14:17 ` Lorenzo Stoakes
[not found] ` <c7dc90e44a9e75e750939ea369290d6e441a18e6.1750099179.git.lorenzo.stoakes@oracle.com>
` (5 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: David Howells @ 2025-06-17 14:05 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
> This is preferred to the existing f_op->mmap() hook as it does require a
> VMA to be established yet,
Did you mean ".. doesn't require a VMA to be established yet, ..."
David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 08/10] fs: convert simple use of generic_file_*_mmap() to .mmap_prepare()
[not found] ` <c7dc90e44a9e75e750939ea369290d6e441a18e6.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 14:07 ` Dave Kleikamp
0 siblings, 0 replies; 21+ messages in thread
From: Dave Kleikamp @ 2025-06-17 14:07 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: 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, Christian Brauner, Jan Kara, Benjamin LaHaise,
Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On 6/16/25 2:33PM, 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().
>
> We have provided generic .mmap_prepare() equivalents, so update all file
> systems that specify these directly in their file_operations structures.
>
> This updates 9p, adfs, affs, bfs, fat, hfs, hfsplus, hostfs, hpfs, jffs2,
> jfs, minix, omfs, ramfs and ufs file systems directly.
>
> It updates generic_ro_fops which impacts qnx4, cramfs, befs, squashfs,
> frebxfs, qnx6, efs, romfs, erofs and isofs file systems.
>
> There are remaining file systems which use generic hooks in a less direct
> way which we address in a subsequent commit.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
For JFS,
Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
> ---
> fs/9p/vfs_file.c | 2 +-
> fs/adfs/file.c | 2 +-
> fs/affs/file.c | 2 +-
> fs/bfs/file.c | 2 +-
> fs/fat/file.c | 2 +-
> fs/hfs/inode.c | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/file.c | 2 +-
> fs/jffs2/file.c | 2 +-
> fs/jfs/file.c | 2 +-
> fs/minix/file.c | 2 +-
> fs/omfs/file.c | 2 +-
> fs/ramfs/file-mmu.c | 2 +-
> fs/read_write.c | 2 +-
> fs/ufs/file.c | 2 +-
> 16 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> index 348cc90bf9c5..2ff3e0ac7266 100644
> --- a/fs/9p/vfs_file.c
> +++ b/fs/9p/vfs_file.c
> @@ -516,7 +516,7 @@ const struct file_operations v9fs_file_operations = {
> .open = v9fs_file_open,
> .release = v9fs_dir_release,
> .lock = v9fs_file_lock,
> - .mmap = generic_file_readonly_mmap,
> + .mmap_prepare = generic_file_readonly_mmap_prepare,
> .splice_read = v9fs_file_splice_read,
> .splice_write = iter_file_splice_write,
> .fsync = v9fs_file_fsync,
> diff --git a/fs/adfs/file.c b/fs/adfs/file.c
> index ee80718aaeec..cd13165fd904 100644
> --- a/fs/adfs/file.c
> +++ b/fs/adfs/file.c
> @@ -25,7 +25,7 @@
> const struct file_operations adfs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .fsync = generic_file_fsync,
> .write_iter = generic_file_write_iter,
> .splice_read = filemap_splice_read,
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index 7a71018e3f67..fbac204b7055 100644
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -999,7 +999,7 @@ const struct file_operations affs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .open = affs_file_open,
> .release = affs_file_release,
> .fsync = affs_file_fsync,
> diff --git a/fs/bfs/file.c b/fs/bfs/file.c
> index fa66a09e496a..6685c3411fe7 100644
> --- a/fs/bfs/file.c
> +++ b/fs/bfs/file.c
> @@ -27,7 +27,7 @@ const struct file_operations bfs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .splice_read = filemap_splice_read,
> };
>
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index e887e9ab7472..4fc49a614fb8 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -204,7 +204,7 @@ const struct file_operations fat_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .release = fat_file_release,
> .unlocked_ioctl = fat_generic_ioctl,
> .compat_ioctl = compat_ptr_ioctl,
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index a81ce7a740b9..d419586d668d 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -690,7 +690,7 @@ static const struct file_operations hfs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .splice_read = filemap_splice_read,
> .fsync = hfs_file_fsync,
> .open = hfs_file_open,
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index f331e9574217..0af7e302730c 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -366,7 +366,7 @@ static const struct file_operations hfsplus_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .splice_read = filemap_splice_read,
> .fsync = hfsplus_file_fsync,
> .open = hfsplus_file_open,
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 702c41317589..bc22b6cc72af 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -382,7 +382,7 @@ static const struct file_operations hostfs_file_fops = {
> .splice_write = iter_file_splice_write,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .open = hostfs_open,
> .release = hostfs_file_release,
> .fsync = hostfs_fsync,
> diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
> index 449a3fc1b8d9..a1a44e3edb19 100644
> --- a/fs/hpfs/file.c
> +++ b/fs/hpfs/file.c
> @@ -255,7 +255,7 @@ const struct file_operations hpfs_file_ops =
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .release = hpfs_file_release,
> .fsync = hpfs_file_fsync,
> .splice_read = filemap_splice_read,
> diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
> index 13c18ccc13b0..1e05f7fe5dd4 100644
> --- a/fs/jffs2/file.c
> +++ b/fs/jffs2/file.c
> @@ -54,7 +54,7 @@ const struct file_operations jffs2_file_operations =
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> .unlocked_ioctl=jffs2_ioctl,
> - .mmap = generic_file_readonly_mmap,
> + .mmap_prepare = generic_file_readonly_mmap_prepare,
> .fsync = jffs2_fsync,
> .splice_read = filemap_splice_read,
> .splice_write = iter_file_splice_write,
> diff --git a/fs/jfs/file.c b/fs/jfs/file.c
> index 01b6912e60f8..5e47951db630 100644
> --- a/fs/jfs/file.c
> +++ b/fs/jfs/file.c
> @@ -143,7 +143,7 @@ const struct file_operations jfs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .splice_read = filemap_splice_read,
> .splice_write = iter_file_splice_write,
> .fsync = jfs_fsync,
> diff --git a/fs/minix/file.c b/fs/minix/file.c
> index 906d192ab7f3..dca7ac71f049 100644
> --- a/fs/minix/file.c
> +++ b/fs/minix/file.c
> @@ -17,7 +17,7 @@ const struct file_operations minix_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .fsync = generic_file_fsync,
> .splice_read = filemap_splice_read,
> };
> diff --git a/fs/omfs/file.c b/fs/omfs/file.c
> index 98358d405b6a..319c04e63964 100644
> --- a/fs/omfs/file.c
> +++ b/fs/omfs/file.c
> @@ -332,7 +332,7 @@ const struct file_operations omfs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .fsync = generic_file_fsync,
> .splice_read = filemap_splice_read,
> };
> diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
> index b45c7edc3225..b11f5b20b78b 100644
> --- a/fs/ramfs/file-mmu.c
> +++ b/fs/ramfs/file-mmu.c
> @@ -41,7 +41,7 @@ static unsigned long ramfs_mmu_get_unmapped_area(struct file *file,
> const struct file_operations ramfs_file_operations = {
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .fsync = noop_fsync,
> .splice_read = filemap_splice_read,
> .splice_write = iter_file_splice_write,
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 0ef70e128c4a..80fdab99f9e4 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -28,7 +28,7 @@
> const struct file_operations generic_ro_fops = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> - .mmap = generic_file_readonly_mmap,
> + .mmap_prepare = generic_file_readonly_mmap_prepare,
> .splice_read = filemap_splice_read,
> };
>
> diff --git a/fs/ufs/file.c b/fs/ufs/file.c
> index 487ad1fc2de6..c2a391c17df7 100644
> --- a/fs/ufs/file.c
> +++ b/fs/ufs/file.c
> @@ -38,7 +38,7 @@ const struct file_operations ufs_file_operations = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> - .mmap = generic_file_mmap,
> + .mmap_prepare = generic_file_mmap_prepare,
> .open = generic_file_open,
> .fsync = generic_file_fsync,
> .splice_read = filemap_splice_read,
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
2025-06-17 14:05 ` David Howells
@ 2025-06-17 14:17 ` Lorenzo Stoakes
0 siblings, 0 replies; 21+ messages in thread
From: Lorenzo Stoakes @ 2025-06-17 14:17 UTC (permalink / raw)
To: David Howells
Cc: 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,
Marc Dionne, Alexander Viro, Christian Brauner, Jan Kara,
Benjamin LaHaise, Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, linux-kernel, intel-gfx, dri-devel, v9fs,
linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Tue, Jun 17, 2025 at 03:05:59PM +0100, David Howells wrote:
> Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>
> > This is preferred to the existing f_op->mmap() hook as it does require a
> > VMA to be established yet,
>
> Did you mean ".. doesn't require a VMA to be established yet, ..."
>
> David
>
Yeah apologies, indeed I did :)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 01/10] mm: rename call_mmap/mmap_prepare to vfs_mmap/mmap_prepare
[not found] ` <8d389f4994fa736aa8f9172bef8533c10a9e9011.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 18:57 ` Vlastimil Babka
0 siblings, 0 replies; 21+ messages in thread
From: Vlastimil Babka @ 2025-06-17 18:57 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: 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, Christian Brauner, Jan Kara, Benjamin LaHaise,
Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, Jann Horn, Pedro Falcato, linux-block,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On 6/16/25 21:33, Lorenzo Stoakes wrote:
> The call_mmap() function violates the existing convention in
> include/linux/fs.h whereby invocations of virtual file system hooks is
> performed by functions prefixed with vfs_xxx().
>
> Correct this by renaming call_mmap() to vfs_mmap(). This also avoids
> confusion as to the fact that f_op->mmap_prepare may be invoked here.
>
> Also rename __call_mmap_prepare() function to vfs_mmap_prepare() and adjust
> to accept a file parameter, this is useful later for nested file systems.
>
> Finally, fix up the VMA userland tests and ensure the mmap_prepare -> mmap
> shim is implemented there.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 +-
> fs/backing-file.c | 2 +-
> fs/coda/file.c | 4 +--
> include/linux/fs.h | 5 ++--
> ipc/shm.c | 2 +-
> mm/internal.h | 2 +-
> mm/vma.c | 2 +-
> tools/testing/vma/vma_internal.h | 32 ++++++++++++++++++----
> 8 files changed, 35 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> index 05e440643aa2..f4f1c979d1b9 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> @@ -105,7 +105,7 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *
> if (!obj->base.filp)
> return -ENODEV;
>
> - ret = call_mmap(obj->base.filp, vma);
> + ret = vfs_mmap(obj->base.filp, vma);
> if (ret)
> return ret;
>
> diff --git a/fs/backing-file.c b/fs/backing-file.c
> index 763fbe9b72b2..04018679bf69 100644
> --- a/fs/backing-file.c
> +++ b/fs/backing-file.c
> @@ -339,7 +339,7 @@ int backing_file_mmap(struct file *file, struct vm_area_struct *vma,
> vma_set_file(vma, file);
>
> old_cred = override_creds(ctx->cred);
> - ret = call_mmap(vma->vm_file, vma);
> + ret = vfs_mmap(vma->vm_file, vma);
> revert_creds(old_cred);
>
> if (ctx->accessed)
> diff --git a/fs/coda/file.c b/fs/coda/file.c
> index 148856a582a9..2e6ea9319b35 100644
> --- a/fs/coda/file.c
> +++ b/fs/coda/file.c
> @@ -199,10 +199,10 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
> spin_unlock(&cii->c_lock);
>
> vma->vm_file = get_file(host_file);
> - ret = call_mmap(vma->vm_file, vma);
> + ret = vfs_mmap(vma->vm_file, vma);
>
> if (ret) {
> - /* if call_mmap fails, our caller will put host_file so we
> + /* if vfs_mmap fails, our caller will put host_file so we
> * should drop the reference to the coda_file that we got.
> */
> fput(coda_file);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 93ee0d2d6f1a..7120f80255b3 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2278,7 +2278,7 @@ static inline bool file_has_valid_mmap_hooks(struct file *file)
>
> int compat_vma_mmap_prepare(struct file *file, struct vm_area_struct *vma);
>
> -static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
> +static inline int vfs_mmap(struct file *file, struct vm_area_struct *vma)
> {
> if (file->f_op->mmap_prepare)
> return compat_vma_mmap_prepare(file, vma);
> @@ -2286,8 +2286,7 @@ static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
> return file->f_op->mmap(file, vma);
> }
>
> -static inline int __call_mmap_prepare(struct file *file,
> - struct vm_area_desc *desc)
> +static inline int vfs_mmap_prepare(struct file *file, struct vm_area_desc *desc)
> {
> return file->f_op->mmap_prepare(desc);
> }
> diff --git a/ipc/shm.c b/ipc/shm.c
> index 492fcc699985..a9310b6dbbc3 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -602,7 +602,7 @@ static int shm_mmap(struct file *file, struct vm_area_struct *vma)
> if (ret)
> return ret;
>
> - ret = call_mmap(sfd->file, vma);
> + ret = vfs_mmap(sfd->file, vma);
> if (ret) {
> __shm_close(sfd);
> return ret;
> diff --git a/mm/internal.h b/mm/internal.h
> index 3823fb356d3b..a55c88afff6d 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -165,7 +165,7 @@ static inline void *folio_raw_mapping(const struct folio *folio)
> */
> static inline int mmap_file(struct file *file, struct vm_area_struct *vma)
> {
> - int err = call_mmap(file, vma);
> + int err = vfs_mmap(file, vma);
>
> if (likely(!err))
> return 0;
> diff --git a/mm/vma.c b/mm/vma.c
> index 5d35adadf2b5..f548bede3bbe 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c
> @@ -2582,7 +2582,7 @@ static int call_mmap_prepare(struct mmap_state *map)
> };
>
> /* Invoke the hook. */
> - err = __call_mmap_prepare(map->file, &desc);
> + err = vfs_mmap_prepare(map->file, &desc);
> if (err)
> return err;
>
> diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h
> index d7fea56e3bb3..51dd122b8d50 100644
> --- a/tools/testing/vma/vma_internal.h
> +++ b/tools/testing/vma/vma_internal.h
> @@ -1458,6 +1458,27 @@ static inline void free_anon_vma_name(struct vm_area_struct *vma)
> (void)vma;
> }
>
> +/* Declared in vma.h. */
> +static inline void set_vma_from_desc(struct vm_area_struct *vma,
> + struct vm_area_desc *desc);
> +
> +static inline struct vm_area_desc *vma_to_desc(struct vm_area_struct *vma,
> + struct vm_area_desc *desc);
> +
> +static int compat_vma_mmap_prepare(struct file *file,
> + struct vm_area_struct *vma)
> +{
> + struct vm_area_desc desc;
> + int err;
> +
> + err = file->f_op->mmap_prepare(vma_to_desc(vma, &desc));
> + if (err)
> + return err;
> + set_vma_from_desc(vma, &desc);
> +
> + return 0;
> +}
> +
> /* Did the driver provide valid mmap hook configuration? */
> static inline bool file_has_valid_mmap_hooks(struct file *file)
> {
> @@ -1467,22 +1488,21 @@ static inline bool file_has_valid_mmap_hooks(struct file *file)
> /* Hooks are mutually exclusive. */
> if (WARN_ON_ONCE(has_mmap && has_mmap_prepare))
> return false;
> - if (WARN_ON_ONCE(!has_mmap && !has_mmap_prepare))
> + if (!has_mmap && !has_mmap_prepare)
> return false;
>
> return true;
> }
>
> -static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
> +static inline int vfs_mmap(struct file *file, struct vm_area_struct *vma)
> {
> - if (WARN_ON_ONCE(file->f_op->mmap_prepare))
> - return -EINVAL;
> + if (file->f_op->mmap_prepare)
> + return compat_vma_mmap_prepare(file, vma);
>
> return file->f_op->mmap(file, vma);
> }
>
> -static inline int __call_mmap_prepare(struct file *file,
> - struct vm_area_desc *desc)
> +static inline int vfs_mmap_prepare(struct file *file, struct vm_area_desc *desc)
> {
> return file->f_op->mmap_prepare(desc);
> }
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 02/10] mm/nommu: use file_has_valid_mmap_hooks() helper
[not found] ` <5f120b644b5890d1b50202d0f0d4c9f0d6b62873.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 18:58 ` Vlastimil Babka
0 siblings, 0 replies; 21+ messages in thread
From: Vlastimil Babka @ 2025-06-17 18:58 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: 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, Christian Brauner, Jan Kara, Benjamin LaHaise,
Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, Jann Horn, Pedro Falcato, linux-block,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On 6/16/25 21:33, 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().
>
> Therefore, update the check for file operations supporting mmap() by using
> the file_has_valid_mmap_hooks() helper function, which checks for either
> f_op->mmap or f_op->mmap_prepare rather than checking only for f_op->mmap
> directly.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/nommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index b624acec6d2e..38c22ea0a95c 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -719,7 +719,7 @@ static int validate_mmap_request(struct file *file,
>
> if (file) {
> /* files must support mmap */
> - if (!file->f_op->mmap)
> + if (!file_has_valid_mmap_hooks(file))
> return -ENODEV;
>
> /* work out if what we've got could possibly be shared
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 07/10] mm/filemap: introduce generic_file_*_mmap_prepare() helpers
[not found] ` <30622c1f0b98c66840bc8c02668bda276a810b70.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-06-17 19:00 ` Vlastimil Babka
0 siblings, 0 replies; 21+ messages in thread
From: Vlastimil Babka @ 2025-06-17 19:00 UTC (permalink / raw)
To: Lorenzo Stoakes, Andrew Morton
Cc: 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, Christian Brauner, Jan Kara, Benjamin LaHaise,
Miklos Szeredi, Amir Goldstein, Kent Overstreet,
Tigran A . Aivazian, Kees Cook, Chris Mason, Josef Bacik,
Xiubo Li, Ilya Dryomov, Jan Harkes, coda, 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, Jann Horn, Pedro Falcato, linux-block,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On 6/16/25 21:33, 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().
>
> The generic mmap handlers are very simple, so we can very easily convert
> these in advance of converting file systems which use them.
>
> This patch does so.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> include/linux/fs.h | 6 ++++--
> mm/filemap.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 7120f80255b3..65cffc445fcc 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3395,8 +3395,10 @@ extern void inode_add_lru(struct inode *inode);
> extern int sb_set_blocksize(struct super_block *, int);
> extern int sb_min_blocksize(struct super_block *, int);
>
> -extern int generic_file_mmap(struct file *, struct vm_area_struct *);
> -extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
> +int generic_file_mmap(struct file *, struct vm_area_struct *);
> +int generic_file_mmap_prepare(struct vm_area_desc *desc);
> +int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
> +int generic_file_readonly_mmap_prepare(struct vm_area_desc *desc);
> extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
> int generic_write_checks_count(struct kiocb *iocb, loff_t *count);
> extern int generic_write_check_limits(struct file *file, loff_t pos,
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 93fbc2ef232a..e75608cbf420 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -3847,6 +3847,18 @@ int generic_file_mmap(struct file *file, struct vm_area_struct *vma)
> return 0;
> }
>
> +int generic_file_mmap_prepare(struct vm_area_desc *desc)
> +{
> + struct file *file = desc->file;
> + struct address_space *mapping = file->f_mapping;
> +
> + if (!mapping->a_ops->read_folio)
> + return -ENOEXEC;
> + file_accessed(file);
> + desc->vm_ops = &generic_file_vm_ops;
> + return 0;
> +}
> +
> /*
> * This is for filesystems which do not implement ->writepage.
> */
> @@ -3856,6 +3868,13 @@ int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
> return -EINVAL;
> return generic_file_mmap(file, vma);
> }
> +
> +int generic_file_readonly_mmap_prepare(struct vm_area_desc *desc)
> +{
> + if (is_shared_maywrite(desc->vm_flags))
> + return -EINVAL;
> + return generic_file_mmap_prepare(desc);
> +}
> #else
> vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf)
> {
> @@ -3865,15 +3884,25 @@ int generic_file_mmap(struct file *file, struct vm_area_struct *vma)
> {
> return -ENOSYS;
> }
> +int generic_file_mmap_prepare(struct vm_area_desc *desc)
> +{
> + return -ENOSYS;
> +}
> int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
> {
> return -ENOSYS;
> }
> +int generic_file_readonly_mmap_prepare(struct vm_area_desc *desc)
> +{
> + return -ENOSYS;
> +}
> #endif /* CONFIG_MMU */
>
> EXPORT_SYMBOL(filemap_page_mkwrite);
> EXPORT_SYMBOL(generic_file_mmap);
> +EXPORT_SYMBOL(generic_file_mmap_prepare);
> EXPORT_SYMBOL(generic_file_readonly_mmap);
> +EXPORT_SYMBOL(generic_file_readonly_mmap_prepare);
>
> static struct folio *do_read_cache_folio(struct address_space *mapping,
> pgoff_t index, filler_t filler, struct file *file, gfp_t gfp)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
[not found] ` <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 10:28 ` [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Jan Kara
@ 2025-06-18 17:06 ` David Sterba
2025-06-19 17:47 ` Ryusuke Konishi
2 siblings, 0 replies; 21+ messages in thread
From: David Sterba @ 2025-06-18 17:06 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On Mon, Jun 16, 2025 at 08:33:29PM +0100, 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 <lorenzo.stoakes@oracle.com>
> ---
For
> fs/btrfs/file.c | 7 ++++---
Acked-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
[not found] ` <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 10:28 ` [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Jan Kara
2025-06-18 17:06 ` David Sterba
@ 2025-06-19 17:47 ` Ryusuke Konishi
2 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2025-06-19 17:47 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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, 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, linux-kernel, intel-gfx, dri-devel,
v9fs, linux-fsdevel, linux-afs, linux-aio, linux-unionfs,
linux-bcachefs, linux-mm, linux-btrfs, ceph-devel, codalist,
ecryptfs, linux-erofs, linux-ext4, linux-f2fs-devel, linux-um,
linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, ntfs3,
ocfs2-devel, linux-karma-devel, devel, linux-cifs,
samba-technical, linux-xfs, nvdimm
On Tue, Jun 17, 2025 at 4:48 AM 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 <lorenzo.stoakes@oracle.com>
For nilfs2,
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Thanks,
Ryusuke Konishi
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] convert the majority of file systems to mmap_prepare
[not found] <cover.1750099179.git.lorenzo.stoakes@oracle.com>
` (13 preceding siblings ...)
[not found] ` <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
@ 2025-08-01 14:00 ` Jason Gunthorpe
14 siblings, 0 replies; 21+ messages in thread
From: Jason Gunthorpe @ 2025-08-01 14:00 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: 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, Christian Brauner,
Jan Kara, Benjamin LaHaise, Miklos Szeredi, Amir Goldstein,
Kent Overstreet, Tigran A . Aivazian, Kees Cook, Chris Mason,
Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
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,
linux-kernel, intel-gfx, dri-devel, v9fs, linux-fsdevel,
linux-afs, linux-aio, linux-unionfs, linux-bcachefs, linux-mm,
linux-btrfs, ceph-devel, codalist, ecryptfs, linux-erofs,
linux-ext4, linux-f2fs-devel, linux-um, linux-mtd, jfs-discussion,
linux-nfs, linux-nilfs, ntfs3, ocfs2-devel, linux-karma-devel,
devel, linux-cifs, samba-technical, linux-xfs, nvdimm
On Mon, Jun 16, 2025 at 08:33:19PM +0100, Lorenzo Stoakes wrote:
> The intent is to gradually deprecate f_op->mmap, and in that vein this
> series coverts the majority of file systems to using f_op->mmap_prepare.
I saw this on lwn and just wanted to give a little bit of thought on
this topic..
It looks to me like we need some more infrastructure to convert
anything that uses remap_pfn/etc in the mmap() callback
I would like to suggest we add a vma->prepopulate() callback which is
where the remap_pfn should go. Once the VMA is finalized and fully
operational the vma_ops have the opportunity to prepopulate any PTEs.
This could then actually be locked properly so it is safe with
concurrent unmap_mapping_range() (current mmap callback is not safe)
Jason
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-08-02 8:22 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-16 19:56 ` [PATCH 00/10] convert the majority of file systems to mmap_prepare Kent Overstreet
[not found] ` <08db85970d89b17a995d2cffae96fb4cc462377f.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 10:23 ` [PATCH 09/10] fs: convert most other generic_file_*mmap() users to .mmap_prepare() Jan Kara
2025-06-17 11:54 ` Christian Brauner
[not found] ` <20250616161111.74e10321c4c421674f78d689@linux-foundation.org>
2025-06-17 11:31 ` [PATCH 00/10] convert the majority of file systems to mmap_prepare Christian Brauner
[not found] ` <b09de1e8544384074165d92d048e80058d971286.1750099179.git.lorenzo.stoakes@oracle.com>
[not found] ` <aFB-Do9FE6H9SsGY@casper.infradead.org>
2025-06-17 11:43 ` [PATCH 04/10] fs/dax: make it possible to check dev dax support without a VMA Christian Brauner
[not found] ` <cba8b29ba5f225df8f63f50182d5f6e0fcf94456.1750099179.git.lorenzo.stoakes@oracle.com>
[not found] ` <aFD4M48RMZB0Hj-f@infradead.org>
2025-06-17 11:45 ` [PATCH 06/10] fs/xfs: transition from deprecated .mmap hook to .mmap_prepare Christian Brauner
[not found] ` <b68145b609532e62bab603dd9686faa6562046ec.1750099179.git.lorenzo.stoakes@oracle.com>
[not found] ` <aFD5AP7B80np-Szz@infradead.org>
[not found] ` <b91c387e-5226-4c5e-94c3-04e80409ed62@lucifer.local>
[not found] ` <kzp4cei5qq6gbtzzng7hmqj5avzblopfzzrks4e2gahcdvr7ro@cwziankavxw4>
2025-06-17 11:48 ` [PATCH 03/10] fs: consistently use file_has_valid_mmap_hooks() helper Christian Brauner
2025-06-17 11:58 ` [PATCH 00/10] convert the majority of file systems to mmap_prepare Christian Brauner
[not found] ` <20250616204149.GK1880847@ZenIV>
2025-06-17 13:45 ` Jeff Layton
2025-06-17 13:46 ` Lorenzo Stoakes
2025-06-17 14:05 ` David Howells
2025-06-17 14:17 ` Lorenzo Stoakes
[not found] ` <c7dc90e44a9e75e750939ea369290d6e441a18e6.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 14:07 ` [PATCH 08/10] fs: convert simple use of generic_file_*_mmap() to .mmap_prepare() Dave Kleikamp
[not found] ` <8d389f4994fa736aa8f9172bef8533c10a9e9011.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 18:57 ` [PATCH 01/10] mm: rename call_mmap/mmap_prepare to vfs_mmap/mmap_prepare Vlastimil Babka
[not found] ` <5f120b644b5890d1b50202d0f0d4c9f0d6b62873.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 18:58 ` [PATCH 02/10] mm/nommu: use file_has_valid_mmap_hooks() helper Vlastimil Babka
[not found] ` <30622c1f0b98c66840bc8c02668bda276a810b70.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 19:00 ` [PATCH 07/10] mm/filemap: introduce generic_file_*_mmap_prepare() helpers Vlastimil Babka
[not found] ` <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
2025-06-17 10:28 ` [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Jan Kara
2025-06-17 11:57 ` Christian Brauner
2025-06-18 17:06 ` David Sterba
2025-06-19 17:47 ` Ryusuke Konishi
2025-08-01 14:00 ` [PATCH 00/10] convert the majority of file systems to mmap_prepare Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).