Fixes for loopback files in btrfs
authorChris Mason <chris.mason@oracle.com>
Fri, 14 Dec 2007 17:56:58 +0000 (12:56 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:58 +0000 (11:03 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/file.c
fs/btrfs/inode.c

index a280b9562221baaabaf9e7bca06967a7b3d9cb63..62fcd79d8ab36e93ecd248fa3a68e15895824991 100644 (file)
@@ -861,6 +861,7 @@ struct file_operations btrfs_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
        .aio_read       = generic_file_aio_read,
+       .splice_read    = generic_file_splice_read,
        .write          = btrfs_file_write,
        .mmap           = btrfs_file_mmap,
        .open           = generic_file_open,
index 41b0c7de7a5916570183e8ed100177c58030e426..e535c50e669bf83baf7d44a00e56c1c80acbbb27 100644 (file)
@@ -1893,8 +1893,19 @@ static void btrfs_truncate(struct inode *inode)
 int btrfs_commit_write(struct file *file, struct page *page,
                       unsigned from, unsigned to)
 {
-       return extent_commit_write(&BTRFS_I(page->mapping->host)->extent_tree,
-                                  page->mapping->host, page, from, to);
+       loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+       struct inode *inode = page->mapping->host;
+
+       btrfs_cow_one_page(inode, page, PAGE_CACHE_SIZE);
+
+       set_page_extent_mapped(page);
+       set_page_dirty(page);
+
+       if (pos > inode->i_size) {
+               i_size_write(inode, pos);
+               mark_inode_dirty(inode);
+       }
+       return 0;
 }
 
 static int create_subvol(struct btrfs_root *root, char *name, int namelen)