Skip to content

Commit 0335f6a

Browse files
ljskernelbrauner
authored andcommitted
fs/dax: make it possible to check dev dax support without a VMA
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>
1 parent b013ed4 commit 0335f6a

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

fs/ext4/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
821821
* We don't support synchronous mappings for non-DAX files and
822822
* for DAX files if underneath dax_device is not synchronous.
823823
*/
824-
if (!daxdev_mapping_supported(vma, dax_dev))
824+
if (!daxdev_mapping_supported(vma->vm_flags, file_inode(vma->vm_file), dax_dev))
825825
return -EOPNOTSUPP;
826826

827827
file_accessed(file);

fs/xfs/xfs_file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,8 @@ xfs_file_mmap(
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, target->bt_daxdev))
1927+
if (!daxdev_mapping_supported(vma->vm_flags, file_inode(vma->vm_file),
1928+
target->bt_daxdev))
19281929
return -EOPNOTSUPP;
19291930

19301931
file_accessed(file);

include/linux/dax.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff,
6565
/*
6666
* Check if given mapping is supported by the file / underlying device.
6767
*/
68-
static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
69-
struct dax_device *dax_dev)
68+
static inline bool daxdev_mapping_supported(vm_flags_t vm_flags,
69+
const struct inode *inode,
70+
struct dax_device *dax_dev)
7071
{
71-
if (!(vma->vm_flags & VM_SYNC))
72+
if (!(vm_flags & VM_SYNC))
7273
return true;
73-
if (!IS_DAX(file_inode(vma->vm_file)))
74+
if (!IS_DAX(inode))
7475
return false;
7576
return dax_synchronous(dax_dev);
7677
}
@@ -110,10 +111,11 @@ static inline void set_dax_nomc(struct dax_device *dax_dev)
110111
static inline void set_dax_synchronous(struct dax_device *dax_dev)
111112
{
112113
}
113-
static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
114-
struct dax_device *dax_dev)
114+
static inline bool daxdev_mapping_supported(vm_flags_t vm_flags,
115+
const struct inode *inode,
116+
struct dax_device *dax_dev)
115117
{
116-
return !(vma->vm_flags & VM_SYNC);
118+
return !(vm_flags & VM_SYNC);
117119
}
118120
static inline size_t dax_recovery_write(struct dax_device *dax_dev,
119121
pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i)

0 commit comments

Comments
 (0)