diff mbox

[06/10] btrfs: fix remap_file_pages error

Message ID 4BF4E30E.3070402@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Miao Xie May 20, 2010, 7:21 a.m. UTC
None
diff mbox

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d146dde..c874833 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -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;
 }