Btrfs: fix remap_file_pages error
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 20 May 2010 07:21:50 +0000 (07:21 +0000)
committerChris Mason <chris.mason@oracle.com>
Fri, 11 Jun 2010 15:46:12 +0000 (11:46 -0400)
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 <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/file.c

index abcb91867b561acbfcb79af76e34f8f13f36abc9..ce0cd29efa9eb4d8e917b312a84da6a2feb5d62d 100644 (file)
@@ -1189,8 +1189,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;
 }