]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/dax: make it possible to check dev dax support without a VMA
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Mon, 16 Jun 2025 19:33:23 +0000 (20:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 17 Jun 2025 11:47:44 +0000 (13:47 +0200)
This is a prerequisite for adapting those filesystems to use the
.mmap_prepare() hook for mmap()'ing which invoke this check as this hook
does not have access to a VMA pointer.

To effect this, change the signature of daxdev_mapping_supported() and
update its callers (ext4 and xfs mmap()'ing hook code).

Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://lore.kernel.org/b09de1e8544384074165d92d048e80058d971286.1750099179.git.lorenzo.stoakes@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ext4/file.c
fs/xfs/xfs_file.c
include/linux/dax.h

index 21df81347147cc7ab3648590b6dbd40e31e2c20b..5b8b95936a4cf47f1b5d81c0dec96c1781873e99 100644 (file)
@@ -821,7 +821,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
         * We don't support synchronous mappings for non-DAX files and
         * for DAX files if underneath dax_device is not synchronous.
         */
-       if (!daxdev_mapping_supported(vma, dax_dev))
+       if (!daxdev_mapping_supported(vma->vm_flags, file_inode(vma->vm_file), dax_dev))
                return -EOPNOTSUPP;
 
        file_accessed(file);
index 48254a72071bc8213b08e1051a9712a0937cbb11..1160eba8727f557fff6e1f682a7b261321382fde 100644 (file)
@@ -1924,7 +1924,8 @@ xfs_file_mmap(
         * We don't support synchronous mappings for non-DAX files and
         * for DAX files if underneath dax_device is not synchronous.
         */
-       if (!daxdev_mapping_supported(vma, target->bt_daxdev))
+       if (!daxdev_mapping_supported(vma->vm_flags, file_inode(vma->vm_file),
+                                     target->bt_daxdev))
                return -EOPNOTSUPP;
 
        file_accessed(file);
index dcc9fcdf14e4396659016d8d9f115ccb6edaf908..78891518291d8a53cf00c2707235cd2c97e2a3dc 100644 (file)
@@ -65,12 +65,13 @@ size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff,
 /*
  * Check if given mapping is supported by the file / underlying device.
  */
-static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
-                                            struct dax_device *dax_dev)
+static inline bool daxdev_mapping_supported(vm_flags_t vm_flags,
+                                           const struct inode *inode,
+                                           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(inode))
                return false;
        return dax_synchronous(dax_dev);
 }
@@ -110,10 +111,11 @@ static inline void set_dax_nomc(struct dax_device *dax_dev)
 static inline void set_dax_synchronous(struct dax_device *dax_dev)
 {
 }
-static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
-                               struct dax_device *dax_dev)
+static inline bool daxdev_mapping_supported(vm_flags_t vm_flags,
+                                           const struct inode *inode,
+                                           struct dax_device *dax_dev)
 {
-       return !(vma->vm_flags & VM_SYNC);
+       return !(vm_flags & VM_SYNC);
 }
 static inline size_t dax_recovery_write(struct dax_device *dax_dev,
                pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i)