aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-10-16 07:33:38 -0400
committerJosef Bacik <jbacik@fusionio.com>2012-12-11 13:31:31 -0500
commit08e007d2e57744472a9424735a368ffe6d625597 (patch)
tree84227c096c05bc4c5430190f0f550b094d3bf2b7 /fs/btrfs/relocation.c
parent561c294d4cfb30c4acfa0a243448fc55af730d87 (diff)
Btrfs: improve the noflush reservation
In some places(such as: evicting inode), we just can not flush the reserved space of delalloc, flushing the delayed directory index and delayed inode is OK, but we don't try to flush those things and just go back when there is no enough space to be reserved. This patch fixes this problem. We defined 3 types of the flush operations: NO_FLUSH, FLUSH_LIMIT and FLUSH_ALL. If we can in the transaction, we should not flush anything, or the deadlock would happen, so use NO_FLUSH. If we flushing the reserved space of delalloc would cause deadlock, use FLUSH_LIMIT. In the other cases, FLUSH_ALL is used, and we will flush all things. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 776f0aa128fc..242d6de4d8eb 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2074,7 +2074,8 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2074 BUG_ON(IS_ERR(trans)); 2074 BUG_ON(IS_ERR(trans));
2075 trans->block_rsv = rc->block_rsv; 2075 trans->block_rsv = rc->block_rsv;
2076 2076
2077 ret = btrfs_block_rsv_refill(root, rc->block_rsv, min_reserved); 2077 ret = btrfs_block_rsv_refill(root, rc->block_rsv, min_reserved,
2078 BTRFS_RESERVE_FLUSH_ALL);
2078 if (ret) { 2079 if (ret) {
2079 BUG_ON(ret != -EAGAIN); 2080 BUG_ON(ret != -EAGAIN);
2080 ret = btrfs_commit_transaction(trans, root); 2081 ret = btrfs_commit_transaction(trans, root);
@@ -2184,7 +2185,8 @@ int prepare_to_merge(struct reloc_control *rc, int err)
2184again: 2185again:
2185 if (!err) { 2186 if (!err) {
2186 num_bytes = rc->merging_rsv_size; 2187 num_bytes = rc->merging_rsv_size;
2187 ret = btrfs_block_rsv_add(root, rc->block_rsv, num_bytes); 2188 ret = btrfs_block_rsv_add(root, rc->block_rsv, num_bytes,
2189 BTRFS_RESERVE_FLUSH_ALL);
2188 if (ret) 2190 if (ret)
2189 err = ret; 2191 err = ret;
2190 } 2192 }
@@ -2459,7 +2461,8 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans,
2459 num_bytes = calcu_metadata_size(rc, node, 1) * 2; 2461 num_bytes = calcu_metadata_size(rc, node, 1) * 2;
2460 2462
2461 trans->block_rsv = rc->block_rsv; 2463 trans->block_rsv = rc->block_rsv;
2462 ret = btrfs_block_rsv_add(root, rc->block_rsv, num_bytes); 2464 ret = btrfs_block_rsv_add(root, rc->block_rsv, num_bytes,
2465 BTRFS_RESERVE_FLUSH_ALL);
2463 if (ret) { 2466 if (ret) {
2464 if (ret == -EAGAIN) 2467 if (ret == -EAGAIN)
2465 rc->commit_transaction = 1; 2468 rc->commit_transaction = 1;
@@ -3685,7 +3688,8 @@ int prepare_to_relocate(struct reloc_control *rc)
3685 * is no reservation in transaction handle. 3688 * is no reservation in transaction handle.
3686 */ 3689 */
3687 ret = btrfs_block_rsv_add(rc->extent_root, rc->block_rsv, 3690 ret = btrfs_block_rsv_add(rc->extent_root, rc->block_rsv,
3688 rc->extent_root->nodesize * 256); 3691 rc->extent_root->nodesize * 256,
3692 BTRFS_RESERVE_FLUSH_ALL);
3689 if (ret) 3693 if (ret)
3690 return ret; 3694 return ret;
3691 3695