On Fri, May 10, 2019 at 8:33 AM Adam Borowski <kilobyte@xxxxxxxxxx> wrote: > > 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 <kilobyte@xxxxxxxxxx> > --- > 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; > + If the virtio-pmem patch set goes upstream prior to btrfs-dax support this will need to switch over to the new daxdev_mapping_supported() helper. https://lore.kernel.org/lkml/20190426050039.17460-5-pagupta@xxxxxxxxxx/