]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Btrfs: Fix delayed allocation to avoid missing delalloc extents
authorChris Mason <chris.mason@oracle.com>
Tue, 18 Dec 2007 21:25:45 +0000 (16:25 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:58 +0000 (11:03 -0400)
find_lock_delalloc_range could exit out too early

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent_map.c
fs/btrfs/inode.c

index 0d1e59a86e490b4a9bf264ff4dc8b72fa40afc78..a0dff34dd437a43f3d8434d9fa4a42685f4c1e8a 100644 (file)
@@ -1070,6 +1070,7 @@ u64 find_lock_delalloc_range(struct extent_map_tree *tree,
 search_again:
        node = tree_search(&tree->state, cur_start);
        if (!node || IS_ERR(node)) {
+               *end = (u64)-1;
                goto out;
        }
 
@@ -1079,6 +1080,8 @@ search_again:
                        goto out;
                }
                if (!(state->state & EXTENT_DELALLOC)) {
+                       if (!found)
+                               *end = state->end;
                        goto out;
                }
                if (!found) {
@@ -1841,8 +1844,10 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
                nr_delalloc = find_lock_delalloc_range(tree, &delalloc_start,
                                                       &delalloc_end,
                                                       128 * 1024 * 1024);
-               if (nr_delalloc <= 0)
-                       break;
+               if (nr_delalloc == 0) {
+                       delalloc_start = delalloc_end + 1;
+                       continue;
+               }
                tree->ops->fill_delalloc(inode, delalloc_start,
                                         delalloc_end);
                clear_extent_bit(tree, delalloc_start,
index 1e725a48467cf17454a35fd7678f1fa5e184baf1..55b2e14260243cfa9312cffc1bd716da6f43eb79 100644 (file)
@@ -798,6 +798,7 @@ static int btrfs_cow_one_page(struct inode *inode, struct page *page,
        u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT;
        u64 page_end = page_start + PAGE_CACHE_SIZE - 1;
 
+       WARN_ON(!PageLocked(page));
        set_page_extent_mapped(page);
 
        lock_extent(em_tree, page_start, page_end, GFP_NOFS);