aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-11-04 10:13:24 -0500
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:13:37 -0500
commit9f3a074d108810139ad4af49a29d347a4cf41e9a (patch)
tree3cf949baa98476e1eb189bce349b34b14af13ce3
parentc61a16a701a12659e2933c5965afe8d45284146a (diff)
Btrfs: don't wait for all the async delalloc when shrinking delalloc
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>
-rw-r--r--fs/btrfs/extent-tree.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d8da538d01fb..83bffbea7d97 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4079,9 +4079,19 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
4079 * We need to wait for the async pages to actually start before 4079 * We need to wait for the async pages to actually start before
4080 * we do anything. 4080 * we do anything.
4081 */ 4081 */
4082 wait_event(root->fs_info->async_submit_wait, 4082 max_reclaim = atomic_read(&root->fs_info->async_delalloc_pages);
4083 !atomic_read(&root->fs_info->async_delalloc_pages)); 4083 if (!max_reclaim)
4084 goto skip_async;
4085
4086 if (max_reclaim <= nr_pages)
4087 max_reclaim = 0;
4088 else
4089 max_reclaim -= nr_pages;
4084 4090
4091 wait_event(root->fs_info->async_submit_wait,
4092 atomic_read(&root->fs_info->async_delalloc_pages) <=
4093 (int)max_reclaim);
4094skip_async:
4085 if (!trans) 4095 if (!trans)
4086 flush = BTRFS_RESERVE_FLUSH_ALL; 4096 flush = BTRFS_RESERVE_FLUSH_ALL;
4087 else 4097 else