]> Pileus Git - ~andy/linux/commitdiff
Btrfs: don't wait for all the async delalloc when shrinking delalloc
authorMiao Xie <miaox@cn.fujitsu.com>
Mon, 4 Nov 2013 15:13:24 +0000 (23:13 +0800)
committerChris Mason <chris.mason@fusionio.com>
Tue, 12 Nov 2013 03:13:37 +0000 (22:13 -0500)
It was very likely that there were lots of async delalloc pages in the
filesystem, if we waited until all the pages were flushed, we would be
blocked for a long time, and the performance would also drop down.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/extent-tree.c

index d8da538d01fb0a944599f4c4fb53393188a6f98b..83bffbea7d978d778c3561e3f059e7c542423a2b 100644 (file)
@@ -4079,9 +4079,19 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
                 * We need to wait for the async pages to actually start before
                 * we do anything.
                 */
-               wait_event(root->fs_info->async_submit_wait,
-                          !atomic_read(&root->fs_info->async_delalloc_pages));
+               max_reclaim = atomic_read(&root->fs_info->async_delalloc_pages);
+               if (!max_reclaim)
+                       goto skip_async;
+
+               if (max_reclaim <= nr_pages)
+                       max_reclaim = 0;
+               else
+                       max_reclaim -= nr_pages;
 
+               wait_event(root->fs_info->async_submit_wait,
+                          atomic_read(&root->fs_info->async_delalloc_pages) <=
+                          (int)max_reclaim);
+skip_async:
                if (!trans)
                        flush = BTRFS_RESERVE_FLUSH_ALL;
                else