]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Btrfs: fix loop device on top of btrfs
authorMiao Xie <miaox@cn.fujitsu.com>
Mon, 7 Jun 2010 03:38:51 +0000 (03:38 +0000)
committerChris Mason <chris.mason@oracle.com>
Fri, 11 Jun 2010 15:46:11 +0000 (11:46 -0400)
We cannot use the loop device which has been connected to a file in the btrf

The reproduce steps is following:
 # dd if=/dev/zero of=vdev0 bs=1M count=1024
 # losetup /dev/loop0 vdev0
 # mkfs.btrfs /dev/loop0
 ...
 failed to zero device start -5

The reason is that the btrfs don't implement either ->write_begin or ->write
the VFS API, so we fix it by setting ->write to do_sync_write().

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/file.c

index 79437c5eeb1efcfd0ca484799d0f79fa525709d9..abcb91867b561acbfcb79af76e34f8f13f36abc9 100644 (file)
@@ -1197,6 +1197,7 @@ static int btrfs_file_mmap(struct file    *filp, struct vm_area_struct *vma)
 const struct file_operations btrfs_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
+       .write          = do_sync_write,
        .aio_read       = generic_file_aio_read,
        .splice_read    = generic_file_splice_read,
        .aio_write      = btrfs_file_aio_write,