Even if allocation is done synchronously, data would be lost except on
actual pmem.  Explicit msync()s don't need MAP_SYNC, and don't require
a sync per page.

Signed-off-by: Adam Borowski <[email protected]>
---
MAP_SYNC can't be allowed unconditionally, as cacheline flushes don't help
guarantee persistency in page cache.  This fixes an error in my earlier
patch "btrfs: allow MAP_SYNC mmap" -- you'd probably want to amend that.


 fs/btrfs/file.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 362a9cf9dcb2..0bc5428037ba 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2233,6 +2233,13 @@ static int btrfs_file_mmap(struct file   *filp, struct 
vm_area_struct *vma)
        if (!IS_DAX(inode) && !mapping->a_ops->readpage)
                return -ENOEXEC;
 
+       /*
+        * Normal operation of btrfs is pretty much an antithesis of MAP_SYNC;
+        * supporting it outside DAX is pointless.
+        */
+       if (!IS_DAX(inode) && (vma->vm_flags & VM_SYNC))
+               return -EOPNOTSUPP;
+
        file_accessed(filp);
        if (IS_DAX(inode))
                vma->vm_ops = &btrfs_dax_vm_ops;
-- 
2.20.1

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to