@@ -102,8 +102,8 @@ static int ext2_dax_pfn_mkwrite(struct vm_area_struct *vma,
{
struct inode *inode = file_inode(vma->vm_file);
struct ext2_inode_info *ei = EXT2_I(inode);
- int ret = VM_FAULT_NOPAGE;
loff_t size;
+ int ret;
sb_start_pagefault(inode->i_sb);
file_update_time(vma->vm_file);
@@ -113,6 +113,8 @@ static int ext2_dax_pfn_mkwrite(struct vm_area_struct *vma,
size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
if (vmf->pgoff >= size)
ret = VM_FAULT_SIGBUS;
+ else
+ ret = dax_pfn_mkwrite(vma, vmf);
up_read(&ei->dax_sem);
sb_end_pagefault(inode->i_sb);
@@ -161,6 +163,16 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct super_block *sb = file->f_mapping->host->i_sb;
struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+#ifdef CONFIG_FS_DAX
+ if (dax_mapping(mapping)) {
+ struct ext2_inode_info *ei = EXT2_I(file_inode(file));
+
+ down_read(&ei->dax_sem);
+ dax_fsync(mapping, start, end);
+ up_read(&ei->dax_sem);
+ }
+#endif
+
ret = generic_file_fsync(file, start, end, datasync);
if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) {
/* We don't really know where the IO error happened... */
To properly support the new DAX fsync/msync infrastructure filesystems need to call dax_pfn_mkwrite() so that DAX can properly track when a user write faults on a previously cleaned address. They also need to call dax_fsync() in the filesystem fsync() path. This dax_fsync() call uses addresses retrieved from get_block() so it needs to be ordered with respect to truncate. This is accomplished by using the same locking that was set up for DAX page faults. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> --- fs/ext2/file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)