aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-10-31 10:07:19 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:08:31 -0500
commit9e6a0c52b74b2d63a6cdb09cec5eaf66038b218f (patch)
tree7582d735115b9bde7527bfc014d10ce8b419b2c6 /fs/btrfs/relocation.c
parent9f23e289edaf1e99f60de3978c50a1c7424f3e92 (diff)
Btrfs: stop committing the transaction so much during relocate
I noticed with my horrible snapshot excercisor that we were taking forever to relocate the larger the file system got. This appeared to be because we were committing the transaction _constantly_. There were a few places where we do braindead things with metadata reservation, like start a transaction and then try to refill the block rsv, which not only keeps us from committing a transaction during the enospc stuff, but keeps us from doing some of the harder flushing work which will make us more likely to need to commit the transaction. We also were checking the block rsv and committing the transaction if the block rsv was below a certain threshold, but we were doing this in a place where we don't actually keep anything in the block rsv so this was always ending up false so we always committed the transaction in this case. I tested this to make sure it didn't break anything, but it takes about 10 hours to get the box to this state so I don't know how much of an impact it will really make. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 729c91e151a3..92eb4832ff86 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2060,7 +2060,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2060 LIST_HEAD(inode_list); 2060 LIST_HEAD(inode_list);
2061 struct btrfs_key key; 2061 struct btrfs_key key;
2062 struct btrfs_key next_key; 2062 struct btrfs_key next_key;
2063 struct btrfs_trans_handle *trans; 2063 struct btrfs_trans_handle *trans = NULL;
2064 struct btrfs_root *reloc_root; 2064 struct btrfs_root *reloc_root;
2065 struct btrfs_root_item *root_item; 2065 struct btrfs_root_item *root_item;
2066 struct btrfs_path *path; 2066 struct btrfs_path *path;
@@ -2109,18 +2109,19 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2109 memset(&next_key, 0, sizeof(next_key)); 2109 memset(&next_key, 0, sizeof(next_key));
2110 2110
2111 while (1) { 2111 while (1) {
2112 trans = btrfs_start_transaction(root, 0);
2113 BUG_ON(IS_ERR(trans));
2114 trans->block_rsv = rc->block_rsv;
2115
2116 ret = btrfs_block_rsv_refill(root, rc->block_rsv, min_reserved, 2112 ret = btrfs_block_rsv_refill(root, rc->block_rsv, min_reserved,
2117 BTRFS_RESERVE_FLUSH_ALL); 2113 BTRFS_RESERVE_FLUSH_ALL);
2118 if (ret) { 2114 if (ret) {
2119 BUG_ON(ret != -EAGAIN); 2115 err = ret;
2120 ret = btrfs_commit_transaction(trans, root); 2116 goto out;
2121 BUG_ON(ret); 2117 }
2122 continue; 2118 trans = btrfs_start_transaction(root, 0);
2119 if (IS_ERR(trans)) {
2120 err = PTR_ERR(trans);
2121 trans = NULL;
2122 goto out;
2123 } 2123 }
2124 trans->block_rsv = rc->block_rsv;
2124 2125
2125 replaced = 0; 2126 replaced = 0;
2126 max_level = level; 2127 max_level = level;
@@ -2166,6 +2167,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2166 root_item->drop_level = level; 2167 root_item->drop_level = level;
2167 2168
2168 btrfs_end_transaction_throttle(trans, root); 2169 btrfs_end_transaction_throttle(trans, root);
2170 trans = NULL;
2169 2171
2170 btrfs_btree_balance_dirty(root); 2172 btrfs_btree_balance_dirty(root);
2171 2173
@@ -2194,7 +2196,8 @@ out:
2194 btrfs_update_reloc_root(trans, root); 2196 btrfs_update_reloc_root(trans, root);
2195 } 2197 }
2196 2198
2197 btrfs_end_transaction_throttle(trans, root); 2199 if (trans)
2200 btrfs_end_transaction_throttle(trans, root);
2198 2201
2199 btrfs_btree_balance_dirty(root); 2202 btrfs_btree_balance_dirty(root);
2200 2203
@@ -3994,16 +3997,6 @@ restart:
3994 } 3997 }
3995 } 3998 }
3996 3999
3997 ret = btrfs_block_rsv_check(rc->extent_root, rc->block_rsv, 5);
3998 if (ret < 0) {
3999 if (ret != -ENOSPC) {
4000 err = ret;
4001 WARN_ON(1);
4002 break;
4003 }
4004 rc->commit_transaction = 1;
4005 }
4006
4007 if (rc->commit_transaction) { 4000 if (rc->commit_transaction) {
4008 rc->commit_transaction = 0; 4001 rc->commit_transaction = 0;
4009 ret = btrfs_commit_transaction(trans, rc->extent_root); 4002 ret = btrfs_commit_transaction(trans, rc->extent_root);