• Bernd Schubert's avatar
    fuse: fix VM_MAYSHARE and direct_io_allow_mmap · 9511176b
    Bernd Schubert authored
    There were multiple issues with direct_io_allow_mmap:
    
     - fuse_link_write_file() was missing, resulting in warnings in
       fuse_write_file_get() and EIO from msync()
    
     - "vma->vm_ops = &fuse_file_vm_ops" was not set, but especially
       fuse_page_mkwrite is needed.
    
    The semantics of invalidate_inode_pages2() is so far not clearly defined in
    fuse_file_mmap.  It dates back to commit 3121bfe7 ("fuse: fix
    "direct_io" private mmap") Though, as direct_io_allow_mmap is a new
    feature, that was for MAP_PRIVATE only.  As invalidate_inode_pages2() is
    calling into fuse_launder_folio() and writes out dirty pages, it should be
    safe to call invalidate_inode_pages2 for MAP_PRIVATE and MAP_SHARED as
    well.
    
    Cc: Hao Xu <howeyxu@tencent.com>
    Cc: stable@vger.kernel.org
    Fixes: e78662e8 ("fuse: add a new fuse init flag to relax restrictions in no cache mode")
    Signed-off-by: default avatarBernd Schubert <bschubert@ddn.com>
    Reviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    9511176b
file.c 80.4 KB