diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-08-01 13:11:41 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:06 -0400 |
commit | 18e35e0ab337ec99c7e03e9ae917745a352c0bb1 (patch) | |
tree | b262ecafb28e5a3e533cae2aa46214bf813bdb2b | |
parent | f87f057b49ee52cf5c627ab27a706e3252767c9f (diff) |
Btrfs: Throttle less often waiting for snapshots to delete
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r-- | fs/btrfs/extent-tree.c | 7 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 14 |
2 files changed, 5 insertions, 16 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 58bceeeda9c5..74bcd48a9c43 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2535,6 +2535,10 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans, | |||
2535 | root_gen, 0, 0, 1); | 2535 | root_gen, 0, 0, 1); |
2536 | BUG_ON(ret); | 2536 | BUG_ON(ret); |
2537 | mutex_unlock(&root->fs_info->alloc_mutex); | 2537 | mutex_unlock(&root->fs_info->alloc_mutex); |
2538 | |||
2539 | atomic_inc(&root->fs_info->throttle_gen); | ||
2540 | wake_up(&root->fs_info->transaction_throttle); | ||
2541 | |||
2538 | continue; | 2542 | continue; |
2539 | } | 2543 | } |
2540 | /* | 2544 | /* |
@@ -2603,7 +2607,6 @@ out: | |||
2603 | root_owner = btrfs_header_owner(parent); | 2607 | root_owner = btrfs_header_owner(parent); |
2604 | root_gen = btrfs_header_generation(parent); | 2608 | root_gen = btrfs_header_generation(parent); |
2605 | 2609 | ||
2606 | |||
2607 | mutex_lock(&root->fs_info->alloc_mutex); | 2610 | mutex_lock(&root->fs_info->alloc_mutex); |
2608 | ret = __btrfs_free_extent(trans, root, bytenr, blocksize, | 2611 | ret = __btrfs_free_extent(trans, root, bytenr, blocksize, |
2609 | root_owner, root_gen, 0, 0, 1); | 2612 | root_owner, root_gen, 0, 0, 1); |
@@ -2726,7 +2729,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root | |||
2726 | } | 2729 | } |
2727 | } | 2730 | } |
2728 | while(1) { | 2731 | while(1) { |
2729 | atomic_inc(&root->fs_info->throttle_gen); | ||
2730 | wret = walk_down_tree(trans, root, path, &level); | 2732 | wret = walk_down_tree(trans, root, path, &level); |
2731 | if (wret > 0) | 2733 | if (wret > 0) |
2732 | break; | 2734 | break; |
@@ -2742,6 +2744,7 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root | |||
2742 | ret = -EAGAIN; | 2744 | ret = -EAGAIN; |
2743 | break; | 2745 | break; |
2744 | } | 2746 | } |
2747 | atomic_inc(&root->fs_info->throttle_gen); | ||
2745 | wake_up(&root->fs_info->transaction_throttle); | 2748 | wake_up(&root->fs_info->transaction_throttle); |
2746 | } | 2749 | } |
2747 | for (i = 0; i <= orig_level; i++) { | 2750 | for (i = 0; i <= orig_level; i++) { |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 66af5140c8ce..a68779499302 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -211,11 +211,9 @@ static void throttle_on_drops(struct btrfs_root *root) | |||
211 | { | 211 | { |
212 | struct btrfs_fs_info *info = root->fs_info; | 212 | struct btrfs_fs_info *info = root->fs_info; |
213 | 213 | ||
214 | harder: | ||
215 | if (atomic_read(&info->throttles)) { | 214 | if (atomic_read(&info->throttles)) { |
216 | DEFINE_WAIT(wait); | 215 | DEFINE_WAIT(wait); |
217 | int thr; | 216 | int thr; |
218 | int harder_count = 0; | ||
219 | thr = atomic_read(&info->throttle_gen); | 217 | thr = atomic_read(&info->throttle_gen); |
220 | 218 | ||
221 | do { | 219 | do { |
@@ -228,18 +226,6 @@ harder: | |||
228 | schedule(); | 226 | schedule(); |
229 | finish_wait(&info->transaction_throttle, &wait); | 227 | finish_wait(&info->transaction_throttle, &wait); |
230 | } while (thr == atomic_read(&info->throttle_gen)); | 228 | } while (thr == atomic_read(&info->throttle_gen)); |
231 | |||
232 | if (harder_count < 5 && | ||
233 | info->total_ref_cache_size > 1 * 1024 * 1024) { | ||
234 | harder_count++; | ||
235 | goto harder; | ||
236 | } | ||
237 | |||
238 | if (harder_count < 10 && | ||
239 | info->total_ref_cache_size > 5 * 1024 * 1024) { | ||
240 | harder_count++; | ||
241 | goto harder; | ||
242 | } | ||
243 | } | 229 | } |
244 | } | 230 | } |
245 | 231 | ||