Skip to contentSkip to conversation

btrfs: fix remap_file_pages error

PATCH In review Miao Xie 2 participants 3 messages May 20, 2010 – May 21, 2010 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

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.

---
 fs/btrfs/file.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
fs/btrfs/file.c +8 -1
index d146dde..c874833 100644
@@ -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
#1 lore raw

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.

author
#2 lore raw
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_space operations 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