btrfs: fix remap_file_pages error
PATCH 6/10 btrfs: fix remap_file_pages error
when we use remap_file_pages() to remap a file, remap_file_pages always return error. It is because btrfs didn't set VM_CAN_NONLINEAR for vma.
Signed-off-by Miao Xie <[email protected]>
--- fs/btrfs/file.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
fs/btrfs/file.c +8 -1
@@ -1150,8 +1150,15 @@ static const struct vm_operations_struct btrfs_file_vm_ops = {static int btrfs_file_mmap (struct file *filp,struct vm_area_struct *vma) { - vma->vm_ops = &btrfs_file_vm_ops; +struct address_space *mapping = filp->f_mapping; + +if (!mapping->a_ops->readpage) +return -ENOEXEC ; +file_accessed (filp); + vma->vm_ops = &btrfs_file_vm_ops; + vma->vm_flags |=VM_CAN_NONLINEAR ; +return 0 ; }
Signature · 1 line
1.6.5.2
fs/btrfs/file.c static const struct vm_operations_struct btrfs_file_vm_ops = { · line 1156
Quoted 2 lines · Miao Xie
fs/btrfs/file.c +2
-0+if (!mapping->a_ops->readpage) +return -ENOEXEC ;
I don't think there's any instance of address_space operations without a readpage method in btrfs.
Quoted 6 lines · Christoph Hellwig
fs/btrfs/file.c static const struct vm_operations_struct btrfs_file_vm_ops = { · line 1156
Quoted 2 lines · Miao Xie
fs/btrfs/file.c +2
-0+if (!mapping->a_ops->readpage) +return -ENOEXEC ;I don't think there's any instance of
address_spaceoperations without a readpage method in btrfs.
But, Btrfs is being developing. Maybe someone implement a instance of address_space without a readpage method in the future. So it is better to check it, just like ext4.
Thanks