aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-07-31 10:48:37 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:05 -0400
commit37d1aeee3990385e9bb436c50c2f7e120a668df6 (patch)
tree6fc0e7beba7161e0400e743b31030b8cbbe29885 /fs/btrfs/transaction.c
parent47ac14fa0f5306c6b97203f4f086bf1fa21dfddb (diff)
Btrfs: Throttle tuning
This avoids waiting for transactions with pages locked by breaking out the code to wait for the current transaction to close into a function called by btrfs_throttle. It also lowers the limits for where we start throttling. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 52c5524896a..66af5140c8c 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -124,17 +124,12 @@ static noinline int record_root_in_trans(struct btrfs_root *root)
return 0;
}
-struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
- int num_blocks, int join)
+static void wait_current_trans(struct btrfs_root *root)
{
- struct btrfs_trans_handle *h =
- kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
struct btrfs_transaction *cur_trans;
- int ret;
- mutex_lock(&root->fs_info->trans_mutex);
cur_trans = root->fs_info->running_transaction;
- if (cur_trans && cur_trans->blocked && !join) {
+ if (cur_trans && cur_trans->blocked) {
DEFINE_WAIT(wait);
cur_trans->use_count++;
while(1) {
@@ -154,6 +149,18 @@ struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
}
put_transaction(cur_trans);
}
+}
+
+struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
+ int num_blocks, int join)
+{
+ struct btrfs_trans_handle *h =
+ kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
+ int ret;
+
+ mutex_lock(&root->fs_info->trans_mutex);
+ if (!join)
+ wait_current_trans(root);
ret = join_transaction(root);
BUG_ON(ret);
@@ -200,7 +207,7 @@ static noinline int wait_for_commit(struct btrfs_root *root,
return 0;
}
-void btrfs_throttle(struct btrfs_root *root)
+static void throttle_on_drops(struct btrfs_root *root)
{
struct btrfs_fs_info *info = root->fs_info;
@@ -223,19 +230,28 @@ harder:
} while (thr == atomic_read(&info->throttle_gen));
if (harder_count < 5 &&
- info->total_ref_cache_size > 5 * 1024 * 1024) {
+ info->total_ref_cache_size > 1 * 1024 * 1024) {
harder_count++;
goto harder;
}
if (harder_count < 10 &&
- info->total_ref_cache_size > 10 * 1024 * 1024) {
+ info->total_ref_cache_size > 5 * 1024 * 1024) {
harder_count++;
goto harder;
}
}
}
+void btrfs_throttle(struct btrfs_root *root)
+{
+ mutex_lock(&root->fs_info->trans_mutex);
+ wait_current_trans(root);
+ mutex_unlock(&root->fs_info->trans_mutex);
+
+ throttle_on_drops(root);
+}
+
static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int throttle)
{
@@ -256,7 +272,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
kmem_cache_free(btrfs_trans_handle_cachep, trans);
if (throttle)
- btrfs_throttle(root);
+ throttle_on_drops(root);
return 0;
}