Skip to content

Commit 6528d29

Browse files
ljskernelbrauner
authored andcommitted
fs/xfs: transition from deprecated .mmap hook to .mmap_prepare
Since commit c84bf6d ("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 bb666b7 ("mm: add mmap_prepare() compatibility layer for nested file systems"). Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Link: https://lore.kernel.org/cba8b29ba5f225df8f63f50182d5f6e0fcf94456.1750099179.git.lorenzo.stoakes@oracle.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 8c90ae8 commit 6528d29

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

fs/xfs/xfs_file.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,25 +1913,25 @@ static const struct vm_operations_struct xfs_file_vm_ops = {
19131913
};
19141914

19151915
STATIC int
1916-
xfs_file_mmap(
1917-
struct file *file,
1918-
struct vm_area_struct *vma)
1916+
xfs_file_mmap_prepare(
1917+
struct vm_area_desc *desc)
19191918
{
1919+
struct file *file = desc->file;
19201920
struct inode *inode = file_inode(file);
19211921
struct xfs_buftarg *target = xfs_inode_buftarg(XFS_I(inode));
19221922

19231923
/*
19241924
* We don't support synchronous mappings for non-DAX files and
19251925
* for DAX files if underneath dax_device is not synchronous.
19261926
*/
1927-
if (!daxdev_mapping_supported(vma->vm_flags, file_inode(vma->vm_file),
1927+
if (!daxdev_mapping_supported(desc->vm_flags, file_inode(file),
19281928
target->bt_daxdev))
19291929
return -EOPNOTSUPP;
19301930

19311931
file_accessed(file);
1932-
vma->vm_ops = &xfs_file_vm_ops;
1932+
desc->vm_ops = &xfs_file_vm_ops;
19331933
if (IS_DAX(inode))
1934-
vm_flags_set(vma, VM_HUGEPAGE);
1934+
desc->vm_flags |= VM_HUGEPAGE;
19351935
return 0;
19361936
}
19371937

@@ -1946,7 +1946,7 @@ const struct file_operations xfs_file_operations = {
19461946
#ifdef CONFIG_COMPAT
19471947
.compat_ioctl = xfs_file_compat_ioctl,
19481948
#endif
1949-
.mmap = xfs_file_mmap,
1949+
.mmap_prepare = xfs_file_mmap_prepare,
19501950
.open = xfs_file_open,
19511951
.release = xfs_file_release,
19521952
.fsync = xfs_file_fsync,

0 commit comments

Comments
 (0)