From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "lorenzo.stoakes@oracle.com" <lorenzo.stoakes@oracle.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "xiang@kernel.org" <xiang@kernel.org>,
"codalist@coda.cs.cmu.edu" <codalist@coda.cs.cmu.edu>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"anna@kernel.org" <anna@kernel.org>,
"vbabka@suse.cz" <vbabka@suse.cz>,
"pfalcato@suse.de" <pfalcato@suse.de>,
"jack@suse.cz" <jack@suse.cz>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
"v9fs@lists.linux.dev" <v9fs@lists.linux.dev>,
"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
"miklos@szeredi.hu" <miklos@szeredi.hu>,
"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"slava@dubeyko.com" <slava@dubeyko.com>,
Hans De Goede <hdegoede@redhat.com>,
"asmadeus@codewreck.org" <asmadeus@codewreck.org>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"jth@kernel.org" <jth@kernel.org>,
"shaggy@kernel.org" <shaggy@kernel.org>,
"willy@infradead.org" <willy@infradead.org>,
"linux-erofs@lists.ozlabs.org" <linux-erofs@lists.ozlabs.org>,
"jaharkes@cs.cmu.edu" <jaharkes@cs.cmu.edu>,
"tursulin@ursulin.net" <tursulin@ursulin.net>,
"trondmy@kernel.org" <trondmy@kernel.org>,
"ecryptfs@vger.kernel.org" <ecryptfs@vger.kernel.org>,
"ericvh@kernel.org" <ericvh@kernel.org>,
"joonas.lahtinen@linux.intel.com"
<joonas.lahtinen@linux.intel.com>,
"hirofumi@mail.parknet.co.jp" <hirofumi@mail.parknet.co.jp>,
"linux-nilfs@vger.kernel.org" <linux-nilfs@vger.kernel.org>,
Xiubo Li <xiubli@redhat.com>,
"aivazian.tigran@gmail.com" <aivazian.tigran@gmail.com>,
"hubcap@omnibond.com" <hubcap@omnibond.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"sfrench@samba.org" <sfrench@samba.org>,
"jfs-discussion@lists.sourceforge.net"
<jfs-discussion@lists.sourceforge.net>, "clm@fb.com" <clm@fb.com>,
"jlbec@evilplan.org" <jlbec@evilplan.org>,
"lihongbo22@huawei.com" <lihongbo22@huawei.com>,
"ronniesahlberg@gmail.com" <ronniesahlberg@gmail.com>,
"lucho@ionkov.net" <lucho@ionkov.net>,
"anton.ivanov@cambridgegreys.com"
<anton.ivanov@cambridgegreys.com>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
"Liam.Howlett@oracle.com" <Liam.Howlett@oracle.com>,
"sj1557.seo@samsung.com" <sj1557.seo@samsung.com>,
"josef@toxicpanda.com" <josef@toxicpanda.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"cem@kernel.org" <cem@kernel.org>,
"linkinjeon@kernel.org" <linkinjeon@kernel.org>,
"tom@talpey.com" <tom@talpey.com>,
"mikulas@artax.karlin.mff.cuni.cz"
<mikulas@artax.karlin.mff.cuni.cz>,
"bcrl@kvack.org" <bcrl@kvack.org>,
"linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>,
"mark@fasheh.com" <mark@fasheh.com>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"bharathsm@microsoft.com" <bharathsm@microsoft.com>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
"linux-f2fs-devel@lists.sourceforge.net"
<linux-f2fs-devel@lists.sourceforge.net>,
"tytso@mit.edu" <tytso@mit.edu>,
"martin@omnibond.com" <martin@omnibond.com>,
"jefflexu@linux.alibaba.com" <jefflexu@linux.alibaba.com>,
"naohiro.aota@wdc.com" <naohiro.aota@wdc.com>,
"frank.li@vivo.com" <frank.li@vivo.com>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"dsterba@suse.com" <dsterba@suse.com>,
"pc@manguebit.org" <pc@manguebit.org>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"code@tyhicks.com" <code@tyhicks.com>,
"ocfs2-devel@lists.linux.dev" <ocfs2-devel@lists.linux.dev>,
"linux-aio@kvack.org" <linux-aio@kvack.org>,
"idryomov@gmail.com" <idryomov@gmail.com>,
"dlemoal@kernel.org" <dlemoal@kernel.org>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"zbestahu@gmail.com" <zbestahu@gmail.com>,
"linux-cifs@vger.kernel.org" <linux-cifs@vger.kernel.org>,
"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
David Howells <dhowells@redhat.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"ntfs3@lists.linux.dev" <ntfs3@lists.linux.dev>,
"richard@nod.at" <richard@nod.at>,
"yuezhang.mo@sony.com" <yuezhang.mo@sony.com>,
"joseph.qi@linux.alibaba.com" <joseph.qi@linux.alibaba.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-karma-devel@lists.sourceforge.net"
<linux-karma-devel@lists.sourceforge.net>,
"kent.overstreet@linux.dev" <kent.overstreet@linux.dev>,
"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
"samba-technical@lists.samba.org"
<samba-technical@lists.samba.org>,
"dhavale@google.com" <dhavale@google.com>,
"devel@lists.orangefs.org" <devel@lists.orangefs.org>,
"konishi.ryusuke@gmail.com" <konishi.ryusuke@gmail.com>,
"linux_oss@crudebyte.com" <linux_oss@crudebyte.com>,
"jaegeuk@kernel.org" <jaegeuk@kernel.org>,
"sprasad@microsoft.com" <sprasad@microsoft.com>,
"linux-um@lists.infradead.org" <linux-um@lists.infradead.org>,
"jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
"brauner@kernel.org" <brauner@kernel.org>,
"rodrigo.vivi@intel.com" <rodrigo.vivi@intel.com>,
"adilger.kernel@dilger.ca" <adilger.kernel@dilger.ca>,
"airlied@gmail.com" <airlied@gmail.com>,
"chao@kernel.org" <chao@kernel.org>,
"coda@cs.cmu.edu" <coda@cs.cmu.edu>,
"jannh@google.com" <jannh@google.com>,
"kees@kernel.org" <kees@kernel.org>,
"me@bobcopeland.com" <me@bobcopeland.com>,
"chengzhihao1@huawei.com" <chengzhihao1@huawei.com>,
"linux-bcachefs@vger.kernel.org" <linux-bcachefs@vger.kernel.org>,
"marc.dionne@auristor.com" <marc.dionne@auristor.com>,
"almaz.alexandrovich@paragon-software.com"
<almaz.alexandrovich@paragon-software.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings
Date: Mon, 16 Jun 2025 23:24:31 +0000 [thread overview]
Message-ID: <30a9d9f8870478d50310f52fb14c8ea91dc1a692.camel@ibm.com> (raw)
In-Reply-To: <f528ac4f35b9378931bd800920fee53fc0c5c74d.1750099179.git.lorenzo.stoakes@oracle.com>
On Mon, 2025-06-16 at 20:33 +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>
> ---
> fs/aio.c | 8 ++++----
> fs/bcachefs/fs.c | 8 ++++----
> fs/btrfs/file.c | 7 ++++---
> fs/ceph/addr.c | 5 +++--
> fs/ceph/file.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/exfat/file.c | 7 ++++---
> fs/f2fs/file.c | 7 ++++---
> fs/nilfs2/file.c | 8 ++++----
> fs/ocfs2/file.c | 4 ++--
> fs/ocfs2/mmap.c | 5 +++--
> fs/ocfs2/mmap.h | 2 +-
> fs/orangefs/file.c | 10 ++++++----
> fs/ramfs/file-nommu.c | 12 ++++++------
> fs/romfs/mmap-nommu.c | 6 +++---
> fs/zonefs/file.c | 10 ++++++----
> 16 files changed, 56 insertions(+), 47 deletions(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index 793b7b15ec4b..7fc7b6221312 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -392,15 +392,15 @@ static const struct vm_operations_struct aio_ring_vm_ops = {
> #endif
> };
>
> -static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma)
> +static int aio_ring_mmap_prepare(struct vm_area_desc *desc)
> {
> - vm_flags_set(vma, VM_DONTEXPAND);
> - vma->vm_ops = &aio_ring_vm_ops;
> + desc->vm_flags |= VM_DONTEXPAND;
> + desc->vm_ops = &aio_ring_vm_ops;
> return 0;
> }
>
> static const struct file_operations aio_ring_fops = {
> - .mmap = aio_ring_mmap,
> + .mmap_prepare = aio_ring_mmap_prepare,
> };
>
> #if IS_ENABLED(CONFIG_MIGRATION)
> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> index 3063a8ddc2df..9c2238edc0e3 100644
> --- a/fs/bcachefs/fs.c
> +++ b/fs/bcachefs/fs.c
> @@ -1553,11 +1553,11 @@ static const struct vm_operations_struct bch_vm_ops = {
> .page_mkwrite = bch2_page_mkwrite,
> };
>
> -static int bch2_mmap(struct file *file, struct vm_area_struct *vma)
> +static int bch2_mmap_prepare(struct vm_area_desc *desc)
> {
> - file_accessed(file);
> + file_accessed(desc->file);
>
> - vma->vm_ops = &bch_vm_ops;
> + desc->vm_ops = &bch_vm_ops;
> return 0;
> }
>
> @@ -1740,7 +1740,7 @@ static const struct file_operations bch_file_operations = {
> .llseek = bch2_llseek,
> .read_iter = bch2_read_iter,
> .write_iter = bch2_write_iter,
> - .mmap = bch2_mmap,
> + .mmap_prepare = bch2_mmap_prepare,
> .get_unmapped_area = thp_get_unmapped_area,
> .fsync = bch2_fsync,
> .splice_read = filemap_splice_read,
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 8ce6f45f45e0..06bd30b35b95 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1978,15 +1978,16 @@ static const struct vm_operations_struct btrfs_file_vm_ops = {
> .page_mkwrite = btrfs_page_mkwrite,
> };
>
> -static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)
> +static int btrfs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *filp = desc->file;
> struct address_space *mapping = filp->f_mapping;
>
> if (!mapping->a_ops->read_folio)
> return -ENOEXEC;
>
> file_accessed(filp);
> - vma->vm_ops = &btrfs_file_vm_ops;
> + desc->vm_ops = &btrfs_file_vm_ops;
>
> return 0;
> }
> @@ -3765,7 +3766,7 @@ const struct file_operations btrfs_file_operations = {
> .splice_read = filemap_splice_read,
> .write_iter = btrfs_file_write_iter,
> .splice_write = iter_file_splice_write,
> - .mmap = btrfs_file_mmap,
> + .mmap_prepare = btrfs_file_mmap_prepare,
> .open = btrfs_file_open,
> .release = btrfs_release_file,
> .get_unmapped_area = thp_get_unmapped_area,
> 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;
>
> if (!mapping->a_ops->read_folio)
> return -ENOEXEC;
> - vma->vm_ops = &ceph_vmops;
> + desc->vm_ops = &ceph_vmops;
> return 0;
> }
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index d5c674d2ba8a..41b8ec33e864 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -3170,7 +3170,7 @@ const struct file_operations ceph_file_fops = {
> .llseek = ceph_llseek,
> .read_iter = ceph_read_iter,
> .write_iter = ceph_write_iter,
> - .mmap = ceph_mmap,
> + .mmap_prepare = ceph_mmap_prepare,
> .fsync = ceph_fsync,
> .lock = ceph_lock,
> .setlease = simple_nosetlease,
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index bb0db0cc8003..cf176aab0f82 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1286,7 +1286,7 @@ extern void __ceph_touch_fmode(struct ceph_inode_info *ci,
> /* addr.c */
> extern const struct address_space_operations ceph_aops;
> extern const struct netfs_request_ops ceph_netfs_ops;
> -extern int ceph_mmap(struct file *file, struct vm_area_struct *vma);
> +int ceph_mmap_prepare(struct vm_area_desc *desc);
> extern int ceph_uninline_data(struct file *file);
> extern int ceph_pool_perm_check(struct inode *inode, int need);
> extern void ceph_pool_perm_destroy(struct ceph_mds_client* mdsc);
Looks good for CephFS.
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Thanks,
Slava.
> 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;
> 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;
> }
>
> @@ -710,7 +711,7 @@ const struct file_operations exfat_file_operations = {
> #ifdef CONFIG_COMPAT
> .compat_ioctl = exfat_compat_ioctl,
> #endif
> - .mmap = exfat_file_mmap,
> + .mmap_prepare = exfat_file_mmap_prepare,
> .fsync = exfat_file_fsync,
> .splice_read = exfat_splice_read,
> .splice_write = iter_file_splice_write,
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 6bd3de64f2a8..7af2b49b7e8a 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -532,8 +532,9 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
> return -EINVAL;
> }
>
> -static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int f2fs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> struct inode *inode = file_inode(file);
>
> if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> @@ -543,7 +544,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
> return -EOPNOTSUPP;
>
> file_accessed(file);
> - vma->vm_ops = &f2fs_file_vm_ops;
> + desc->vm_ops = &f2fs_file_vm_ops;
>
> f2fs_down_read(&F2FS_I(inode)->i_sem);
> set_inode_flag(inode, FI_MMAP_FILE);
> @@ -5376,7 +5377,7 @@ const struct file_operations f2fs_file_operations = {
> .iopoll = iocb_bio_iopoll,
> .open = f2fs_file_open,
> .release = f2fs_release_file,
> - .mmap = f2fs_file_mmap,
> + .mmap_prepare = f2fs_file_mmap_prepare,
> .flush = f2fs_file_flush,
> .fsync = f2fs_sync_file,
> .fallocate = f2fs_fallocate,
> diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
> index 0e3fc5ba33c7..1b8d754db44d 100644
> --- a/fs/nilfs2/file.c
> +++ b/fs/nilfs2/file.c
> @@ -125,10 +125,10 @@ static const struct vm_operations_struct nilfs_file_vm_ops = {
> .page_mkwrite = nilfs_page_mkwrite,
> };
>
> -static int nilfs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int nilfs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> - file_accessed(file);
> - vma->vm_ops = &nilfs_file_vm_ops;
> + file_accessed(desc->file);
> + desc->vm_ops = &nilfs_file_vm_ops;
> return 0;
> }
>
> @@ -144,7 +144,7 @@ const struct file_operations nilfs_file_operations = {
> #ifdef CONFIG_COMPAT
> .compat_ioctl = nilfs_compat_ioctl,
> #endif /* CONFIG_COMPAT */
> - .mmap = nilfs_file_mmap,
> + .mmap_prepare = nilfs_file_mmap_prepare,
> .open = generic_file_open,
> /* .release = nilfs_release_file, */
> .fsync = nilfs_sync_file,
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 2056cf08ac1e..21d797ccccd0 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2800,7 +2800,7 @@ const struct inode_operations ocfs2_special_file_iops = {
> */
> const struct file_operations ocfs2_fops = {
> .llseek = ocfs2_file_llseek,
> - .mmap = ocfs2_mmap,
> + .mmap_prepare = ocfs2_mmap_prepare,
> .fsync = ocfs2_sync_file,
> .release = ocfs2_file_release,
> .open = ocfs2_file_open,
> @@ -2850,7 +2850,7 @@ const struct file_operations ocfs2_dops = {
> */
> const struct file_operations ocfs2_fops_no_plocks = {
> .llseek = ocfs2_file_llseek,
> - .mmap = ocfs2_mmap,
> + .mmap_prepare = ocfs2_mmap_prepare,
> .fsync = ocfs2_sync_file,
> .release = ocfs2_file_release,
> .open = ocfs2_file_open,
> diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
> index 6a314e9f2b49..50e2faf64c19 100644
> --- a/fs/ocfs2/mmap.c
> +++ b/fs/ocfs2/mmap.c
> @@ -159,8 +159,9 @@ static const struct vm_operations_struct ocfs2_file_vm_ops = {
> .page_mkwrite = ocfs2_page_mkwrite,
> };
>
> -int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
> +int ocfs2_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> int ret = 0, lock_level = 0;
>
> ret = ocfs2_inode_lock_atime(file_inode(file),
> @@ -171,7 +172,7 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
> }
> ocfs2_inode_unlock(file_inode(file), lock_level);
> out:
> - vma->vm_ops = &ocfs2_file_vm_ops;
> + desc->vm_ops = &ocfs2_file_vm_ops;
> return 0;
> }
>
> diff --git a/fs/ocfs2/mmap.h b/fs/ocfs2/mmap.h
> index 1051507cc684..d21c30de6b8c 100644
> --- a/fs/ocfs2/mmap.h
> +++ b/fs/ocfs2/mmap.h
> @@ -2,6 +2,6 @@
> #ifndef OCFS2_MMAP_H
> #define OCFS2_MMAP_H
>
> -int ocfs2_mmap(struct file *file, struct vm_area_struct *vma);
> +int ocfs2_mmap_prepare(struct vm_area_desc *desc);
>
> #endif /* OCFS2_MMAP_H */
> diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
> index 90c49c0de243..919f99b16834 100644
> --- a/fs/orangefs/file.c
> +++ b/fs/orangefs/file.c
> @@ -398,8 +398,9 @@ static const struct vm_operations_struct orangefs_file_vm_ops = {
> /*
> * Memory map a region of a file.
> */
> -static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int orangefs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> int ret;
>
> ret = orangefs_revalidate_mapping(file_inode(file));
> @@ -410,10 +411,11 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma)
> "orangefs_file_mmap: called on %pD\n", file);
>
> /* set the sequential readahead hint */
> - vm_flags_mod(vma, VM_SEQ_READ, VM_RAND_READ);
> + desc->vm_flags |= VM_SEQ_READ;
> + desc->vm_flags &= ~VM_RAND_READ;
>
> file_accessed(file);
> - vma->vm_ops = &orangefs_file_vm_ops;
> + desc->vm_ops = &orangefs_file_vm_ops;
> return 0;
> }
>
> @@ -574,7 +576,7 @@ const struct file_operations orangefs_file_operations = {
> .read_iter = orangefs_file_read_iter,
> .write_iter = orangefs_file_write_iter,
> .lock = orangefs_lock,
> - .mmap = orangefs_file_mmap,
> + .mmap_prepare = orangefs_file_mmap_prepare,
> .open = generic_file_open,
> .splice_read = orangefs_file_splice_read,
> .splice_write = iter_file_splice_write,
> diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
> index 7a6d980e614d..77b8ca2757e0 100644
> --- a/fs/ramfs/file-nommu.c
> +++ b/fs/ramfs/file-nommu.c
> @@ -28,7 +28,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
> unsigned long len,
> unsigned long pgoff,
> unsigned long flags);
> -static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma);
> +static int ramfs_nommu_mmap_prepare(struct vm_area_desc *desc);
>
> static unsigned ramfs_mmap_capabilities(struct file *file)
> {
> @@ -38,7 +38,7 @@ static unsigned ramfs_mmap_capabilities(struct file *file)
>
> const struct file_operations ramfs_file_operations = {
> .mmap_capabilities = ramfs_mmap_capabilities,
> - .mmap = ramfs_nommu_mmap,
> + .mmap_prepare = ramfs_nommu_mmap_prepare,
> .get_unmapped_area = ramfs_nommu_get_unmapped_area,
> .read_iter = generic_file_read_iter,
> .write_iter = generic_file_write_iter,
> @@ -262,12 +262,12 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
> /*
> * set up a mapping for shared memory segments
> */
> -static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
> +static int ramfs_nommu_mmap_prepare(struct vm_area_desc *desc)
> {
> - if (!is_nommu_shared_mapping(vma->vm_flags))
> + if (!is_nommu_shared_mapping(desc->vm_flags))
> return -ENOSYS;
>
> - file_accessed(file);
> - vma->vm_ops = &generic_file_vm_ops;
> + file_accessed(desc->file);
> + desc->vm_ops = &generic_file_vm_ops;
> return 0;
> }
> diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
> index 4520ca413867..4b77c6dc4418 100644
> --- a/fs/romfs/mmap-nommu.c
> +++ b/fs/romfs/mmap-nommu.c
> @@ -61,9 +61,9 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
> * permit a R/O mapping to be made directly through onto an MTD device if
> * possible
> */
> -static int romfs_mmap(struct file *file, struct vm_area_struct *vma)
> +static int romfs_mmap_prepare(struct vm_area_desc *desc)
> {
> - return is_nommu_shared_mapping(vma->vm_flags) ? 0 : -ENOSYS;
> + return is_nommu_shared_mapping(desc->vm_flags) ? 0 : -ENOSYS;
> }
>
> static unsigned romfs_mmap_capabilities(struct file *file)
> @@ -79,7 +79,7 @@ const struct file_operations romfs_ro_fops = {
> .llseek = generic_file_llseek,
> .read_iter = generic_file_read_iter,
> .splice_read = filemap_splice_read,
> - .mmap = romfs_mmap,
> + .mmap_prepare = romfs_mmap_prepare,
> .get_unmapped_area = romfs_get_unmapped_area,
> .mmap_capabilities = romfs_mmap_capabilities,
> };
> diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
> index 42e2c0065bb3..c1848163b378 100644
> --- a/fs/zonefs/file.c
> +++ b/fs/zonefs/file.c
> @@ -312,8 +312,10 @@ static const struct vm_operations_struct zonefs_file_vm_ops = {
> .page_mkwrite = zonefs_filemap_page_mkwrite,
> };
>
> -static int zonefs_file_mmap(struct file *file, struct vm_area_struct *vma)
> +static int zonefs_file_mmap_prepare(struct vm_area_desc *desc)
> {
> + struct file *file = desc->file;
> +
> /*
> * Conventional zones accept random writes, so their files can support
> * shared writable mappings. For sequential zone files, only read
> @@ -321,11 +323,11 @@ static int zonefs_file_mmap(struct file *file, struct vm_area_struct *vma)
> * ordering between msync() and page cache writeback.
> */
> if (zonefs_inode_is_seq(file_inode(file)) &&
> - (vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
> + (desc->vm_flags & VM_SHARED) && (desc->vm_flags & VM_MAYWRITE))
> return -EINVAL;
>
> file_accessed(file);
> - vma->vm_ops = &zonefs_file_vm_ops;
> + desc->vm_ops = &zonefs_file_vm_ops;
>
> return 0;
> }
> @@ -850,7 +852,7 @@ const struct file_operations zonefs_file_operations = {
> .open = zonefs_file_open,
> .release = zonefs_file_release,
> .fsync = zonefs_file_fsync,
> - .mmap = zonefs_file_mmap,
> + .mmap_prepare = zonefs_file_mmap_prepare,
> .llseek = zonefs_file_llseek,
> .read_iter = zonefs_file_read_iter,
> .write_iter = zonefs_file_write_iter,
next prev parent reply other threads:[~2025-06-16 23:26 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 19:33 [PATCH 00/10] convert the majority of file systems to mmap_prepare Lorenzo Stoakes
2025-06-16 19:33 ` [PATCH 01/10] mm: rename call_mmap/mmap_prepare to vfs_mmap/mmap_prepare Lorenzo Stoakes
2025-06-17 5:10 ` Christoph Hellwig
2025-06-17 5:29 ` Lorenzo Stoakes
2025-06-17 18:57 ` Vlastimil Babka
2025-06-16 19:33 ` [PATCH 02/10] mm/nommu: use file_has_valid_mmap_hooks() helper Lorenzo Stoakes
2025-06-17 10:05 ` Jan Kara
2025-06-17 18:58 ` Vlastimil Babka
2025-06-16 19:33 ` [PATCH 03/10] fs: consistently " Lorenzo Stoakes
2025-06-16 20:01 ` Kees Cook
2025-06-17 5:11 ` Christoph Hellwig
2025-06-17 5:25 ` Lorenzo Stoakes
2025-06-17 5:29 ` Christoph Hellwig
2025-06-17 10:08 ` Jan Kara
2025-06-17 11:48 ` Christian Brauner
2025-06-16 19:33 ` [PATCH 04/10] fs/dax: make it possible to check dev dax support without a VMA Lorenzo Stoakes
2025-06-16 20:26 ` Matthew Wilcox
2025-06-17 11:43 ` Christian Brauner
2025-06-16 19:33 ` [PATCH 05/10] fs/ext4: transition from deprecated .mmap hook to .mmap_prepare Lorenzo Stoakes
2025-06-17 10:11 ` Jan Kara
2025-06-16 19:33 ` [PATCH 06/10] fs/xfs: " Lorenzo Stoakes
2025-06-17 5:08 ` Christoph Hellwig
2025-06-17 11:45 ` Christian Brauner
2025-06-16 19:33 ` [PATCH 07/10] mm/filemap: introduce generic_file_*_mmap_prepare() helpers Lorenzo Stoakes
2025-06-17 10:12 ` Jan Kara
2025-06-17 19:00 ` Vlastimil Babka
2025-06-16 19:33 ` [PATCH 08/10] fs: convert simple use of generic_file_*_mmap() to .mmap_prepare() Lorenzo Stoakes
2025-06-16 23:26 ` Viacheslav Dubeyko
2025-06-17 10:14 ` Jan Kara
2025-06-17 14:07 ` Dave Kleikamp
2025-06-16 19:33 ` [PATCH 09/10] fs: convert most other generic_file_*mmap() users " Lorenzo Stoakes
2025-06-17 10:23 ` Jan Kara
2025-06-17 11:54 ` Christian Brauner
2025-06-16 19:33 ` [PATCH 10/10] fs: replace mmap hook with .mmap_prepare for simple mappings Lorenzo Stoakes
2025-06-16 22:51 ` Damien Le Moal
2025-06-16 23:24 ` Viacheslav Dubeyko [this message]
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
2025-06-16 19:56 ` [PATCH 00/10] convert the majority of file systems to mmap_prepare Kent Overstreet
2025-06-16 20:41 ` Al Viro
2025-06-17 13:45 ` Jeff Layton
2025-06-17 13:46 ` Lorenzo Stoakes
2025-06-16 23:11 ` Andrew Morton
2025-06-17 11:31 ` Christian Brauner
2025-06-17 11:58 ` Christian Brauner
2025-06-17 14:05 ` David Howells
2025-06-17 14:17 ` Lorenzo Stoakes
2025-08-01 14:00 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30a9d9f8870478d50310f52fb14c8ea91dc1a692.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=Liam.Howlett@oracle.com \
--cc=adilger.kernel@dilger.ca \
--cc=airlied@gmail.com \
--cc=aivazian.tigran@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=amir73il@gmail.com \
--cc=anna@kernel.org \
--cc=anton.ivanov@cambridgegreys.com \
--cc=asmadeus@codewreck.org \
--cc=axboe@kernel.dk \
--cc=bcrl@kvack.org \
--cc=bharathsm@microsoft.com \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=chao@kernel.org \
--cc=chengzhihao1@huawei.com \
--cc=clm@fb.com \
--cc=coda@cs.cmu.edu \
--cc=codalist@coda.cs.cmu.edu \
--cc=code@tyhicks.com \
--cc=dan.j.williams@intel.com \
--cc=devel@lists.orangefs.org \
--cc=dhavale@google.com \
--cc=dhowells@redhat.com \
--cc=dlemoal@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=dsterba@suse.com \
--cc=dwmw2@infradead.org \
--cc=ecryptfs@vger.kernel.org \
--cc=ericvh@kernel.org \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=hdegoede@redhat.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=hubcap@omnibond.com \
--cc=idryomov@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=jaharkes@cs.cmu.edu \
--cc=jani.nikula@linux.intel.com \
--cc=jannh@google.com \
--cc=jefflexu@linux.alibaba.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jlbec@evilplan.org \
--cc=johannes@sipsolutions.net \
--cc=joonas.lahtinen@linux.intel.com \
--cc=josef@toxicpanda.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=jth@kernel.org \
--cc=kees@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=konishi.ryusuke@gmail.com \
--cc=lihongbo22@huawei.com \
--cc=linkinjeon@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-aio@kvack.org \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-karma-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=lucho@ionkov.net \
--cc=marc.dionne@auristor.com \
--cc=mark@fasheh.com \
--cc=martin@omnibond.com \
--cc=me@bobcopeland.com \
--cc=miklos@szeredi.hu \
--cc=mikulas@artax.karlin.mff.cuni.cz \
--cc=naohiro.aota@wdc.com \
--cc=ntfs3@lists.linux.dev \
--cc=nvdimm@lists.linux.dev \
--cc=ocfs2-devel@lists.linux.dev \
--cc=pc@manguebit.org \
--cc=pfalcato@suse.de \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=shaggy@kernel.org \
--cc=simona@ffwll.ch \
--cc=sj1557.seo@samsung.com \
--cc=slava@dubeyko.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=tursulin@ursulin.net \
--cc=tytso@mit.edu \
--cc=v9fs@lists.linux.dev \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=xiang@kernel.org \
--cc=xiubli@redhat.com \
--cc=yuezhang.mo@sony.com \
--cc=zbestahu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).