aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-09-17 10:58:06 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:00:48 -0400
commitd3c2fdcf7b79079f60ac64e61d886964d4647910 (patch)
tree146379e460b1209fef52635bf8e581c68864a452 /fs/btrfs/transaction.c
parent7d7d6068bee9d8004ea7cc8a2ebda2c99a57caec (diff)
Btrfs: Use balance_dirty_pages_nr on btree blocks
btrfs_btree_balance_dirty is changed to pass the number of pages dirtied for more accurate dirty throttling. This lets the VM make better decisions about when to force some writeback. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 29755593de65..087074db0bd5 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/writeback.h>
21#include "ctree.h" 22#include "ctree.h"
22#include "disk-io.h" 23#include "disk-io.h"
23#include "transaction.h" 24#include "transaction.h"
@@ -340,6 +341,7 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
340 struct btrfs_fs_info *info = root->fs_info; 341 struct btrfs_fs_info *info = root->fs_info;
341 int ret; 342 int ret;
342 struct btrfs_trans_handle *trans; 343 struct btrfs_trans_handle *trans;
344 unsigned long nr;
343 345
344 if (root->defrag_running) 346 if (root->defrag_running)
345 return 0; 347 return 0;
@@ -348,10 +350,11 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
348 while (1) { 350 while (1) {
349 root->defrag_running = 1; 351 root->defrag_running = 1;
350 ret = btrfs_defrag_leaves(trans, root, cacheonly); 352 ret = btrfs_defrag_leaves(trans, root, cacheonly);
353 nr = trans->blocks_used;
351 btrfs_end_transaction(trans, root); 354 btrfs_end_transaction(trans, root);
352 mutex_unlock(&info->fs_mutex); 355 mutex_unlock(&info->fs_mutex);
353 356
354 btrfs_btree_balance_dirty(root); 357 btrfs_btree_balance_dirty(info->tree_root, nr);
355 cond_resched(); 358 cond_resched();
356 359
357 mutex_lock(&info->fs_mutex); 360 mutex_lock(&info->fs_mutex);
@@ -398,6 +401,7 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
398{ 401{
399 struct dirty_root *dirty; 402 struct dirty_root *dirty;
400 struct btrfs_trans_handle *trans; 403 struct btrfs_trans_handle *trans;
404 unsigned long nr;
401 u64 num_blocks; 405 u64 num_blocks;
402 u64 blocks_used; 406 u64 blocks_used;
403 int ret = 0; 407 int ret = 0;
@@ -426,11 +430,11 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
426 &dirty->root->root_item); 430 &dirty->root->root_item);
427 if (err) 431 if (err)
428 ret = err; 432 ret = err;
433 nr = trans->blocks_used;
429 ret = btrfs_end_transaction(trans, tree_root); 434 ret = btrfs_end_transaction(trans, tree_root);
430 BUG_ON(ret); 435 BUG_ON(ret);
431 mutex_unlock(&tree_root->fs_info->fs_mutex); 436 mutex_unlock(&tree_root->fs_info->fs_mutex);
432 437 btrfs_btree_balance_dirty(tree_root, nr);
433 btrfs_btree_balance_dirty(tree_root);
434 schedule(); 438 schedule();
435 439
436 mutex_lock(&tree_root->fs_info->fs_mutex); 440 mutex_lock(&tree_root->fs_info->fs_mutex);
@@ -449,13 +453,15 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
449 BUG(); 453 BUG();
450 break; 454 break;
451 } 455 }
456 nr = trans->blocks_used;
452 ret = btrfs_end_transaction(trans, tree_root); 457 ret = btrfs_end_transaction(trans, tree_root);
453 BUG_ON(ret); 458 BUG_ON(ret);
454 459
455 kfree(dirty->root); 460 kfree(dirty->root);
456 kfree(dirty); 461 kfree(dirty);
457 mutex_unlock(&tree_root->fs_info->fs_mutex); 462 mutex_unlock(&tree_root->fs_info->fs_mutex);
458 btrfs_btree_balance_dirty(tree_root); 463
464 btrfs_btree_balance_dirty(tree_root, nr);
459 schedule(); 465 schedule();
460 } 466 }
461 return ret; 467 return ret;