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> --- fs/btrfs/file.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) 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; } -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Christoph Hellwig
2010-May-20 08:32 UTC
Re: [PATCH 06/10] btrfs: fix remap_file_pages error
On Thu, May 20, 2010 at 03:21:50PM +0800, Miao Xie wrote:> + 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. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
on 2010-5-20 16:32, Christoph Hellwig wrote:> On Thu, May 20, 2010 at 03:21:50PM +0800, Miao Xie wrote: >> + 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html