From 70b99e6959a4c28ae1b314985eca731f3db72f1d Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 31 Oct 2008 12:46:39 -0400 Subject: 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 --- fs/btrfs/extent_io.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'fs/btrfs/extent_io.c') diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index eb3c12e7beaf..9b37ce6e5168 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1242,12 +1242,21 @@ again: delalloc_end = 0; found = find_delalloc_range(tree, &delalloc_start, &delalloc_end, max_bytes); - if (!found) { + if (!found || delalloc_end <= *start) { *start = delalloc_start; *end = delalloc_end; return found; } + /* + * start comes from the offset of locked_page. We have to lock + * pages in order, so we can't process delalloc bytes before + * locked_page + */ + if (delalloc_start < *start) { + delalloc_start = *start; + } + /* * make sure to limit the number of pages we try to lock down * if we're looping. -- cgit v1.2.2