summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-10-31 17:46:39 +0100
committerChris Mason <chris.mason@oracle.com>2008-10-31 17:46:39 +0100
commit70b99e6959a4c28ae1b314985eca731f3db72f1d (patch)
tree81578759fe422f7b17a734b8bf16b042aa02a046 /fs/btrfs/inode.c
parentBtrfs: Add fallocate support v2 (diff)
downloadlinux-70b99e6959a4c28ae1b314985eca731f3db72f1d.tar.xz
linux-70b99e6959a4c28ae1b314985eca731f3db72f1d.zip
Btrfs: Compression corner fixes
Make sure we keep page->mapping NULL on the pages we're getting via alloc_page. It gets set so a few of the callbacks can do the right thing, but in general these pages don't have a mapping. Don't try to truncate compressed inline items in btrfs_drop_extents. The whole compressed item must be preserved. Don't try to create multipage inline compressed items. When we try to overwrite just the first page of the file, we would have to read in and recow all the pages after it in the same compressed inline items. For now, only create single page inline items. Make sure we lock pages in the correct order during delalloc. The search into the state tree for delalloc bytes can return bytes before the page we already have locked. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 789c376157f9..806708dd7e38 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -239,6 +239,7 @@ static int cow_file_range_inline(struct btrfs_trans_handle *trans,
data_len = compressed_size;
if (start > 0 ||
+ actual_end >= PAGE_CACHE_SIZE ||
data_len >= BTRFS_MAX_INLINE_DATA_SIZE(root) ||
(!compressed_size &&
(actual_end & (root->sectorsize - 1)) == 0) ||
@@ -248,7 +249,7 @@ static int cow_file_range_inline(struct btrfs_trans_handle *trans,
}
ret = btrfs_drop_extents(trans, root, inode, start,
- aligned_end, aligned_end, &hint_byte);
+ aligned_end, start, &hint_byte);
BUG_ON(ret);
if (isize > actual_end)
@@ -423,6 +424,7 @@ again:
* free any pages it allocated and our page pointer array
*/
for (i = 0; i < nr_pages_ret; i++) {
+ WARN_ON(pages[i]->mapping);
page_cache_release(pages[i]);
}
kfree(pages);
@@ -572,8 +574,10 @@ free_pages_out_fail:
extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree,
start, end, locked_page, 0, 0, 0);
free_pages_out:
- for (i = 0; i < nr_pages_ret; i++)
+ for (i = 0; i < nr_pages_ret; i++) {
+ WARN_ON(pages[i]->mapping);
page_cache_release(pages[i]);
+ }
if (pages)
kfree(pages);