aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-08-08 13:33:21 -0400
committerJosef Bacik <josef@redhat.com>2011-10-19 15:12:35 -0400
commit13553e5221d6901a33b3f2157a389de085c161fe (patch)
tree47cbcd85dc148eb4948ecb9728178df31ed7644c
parentdabdb6408cb801644fa613c7432da012640b348c (diff)
Btrfs: don't try to commit in btrfs_block_rsv_check
We will try and reserve metadata bytes in btrfs_block_rsv_check and if we cannot because we have a transaction open it will return EAGAIN, so we do not need to try and commit the transaction again. Signed-off-by: Josef Bacik <josef@redhat.com>
-rw-r--r--fs/btrfs/extent-tree.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5395cc639270..6356ef2f0c80 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3708,7 +3708,6 @@ int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
3708 u64 min_reserved, int min_factor) 3708 u64 min_reserved, int min_factor)
3709{ 3709{
3710 u64 num_bytes = 0; 3710 u64 num_bytes = 0;
3711 int commit_trans = 0;
3712 int ret = -ENOSPC; 3711 int ret = -ENOSPC;
3713 3712
3714 if (!block_rsv) 3713 if (!block_rsv)
@@ -3720,13 +3719,12 @@ int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
3720 if (min_reserved > num_bytes) 3719 if (min_reserved > num_bytes)
3721 num_bytes = min_reserved; 3720 num_bytes = min_reserved;
3722 3721
3723 if (block_rsv->reserved >= num_bytes) { 3722 if (block_rsv->reserved >= num_bytes)
3724 ret = 0; 3723 ret = 0;
3725 } else { 3724 else
3726 num_bytes -= block_rsv->reserved; 3725 num_bytes -= block_rsv->reserved;
3727 commit_trans = 1;
3728 }
3729 spin_unlock(&block_rsv->lock); 3726 spin_unlock(&block_rsv->lock);
3727
3730 if (!ret) 3728 if (!ret)
3731 return 0; 3729 return 0;
3732 3730
@@ -3736,26 +3734,7 @@ int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
3736 return 0; 3734 return 0;
3737 } 3735 }
3738 3736
3739 if (commit_trans) { 3737 return ret;
3740 struct btrfs_space_info *sinfo = block_rsv->space_info;
3741
3742 if (trans)
3743 return -EAGAIN;
3744
3745 spin_lock(&sinfo->lock);
3746 if (sinfo->bytes_pinned < num_bytes) {
3747 spin_unlock(&sinfo->lock);
3748 return -ENOSPC;
3749 }
3750 spin_unlock(&sinfo->lock);
3751
3752 trans = btrfs_join_transaction(root);
3753 BUG_ON(IS_ERR(trans));
3754 ret = btrfs_commit_transaction(trans, root);
3755 return 0;
3756 }
3757
3758 return -ENOSPC;
3759} 3738}
3760 3739
3761int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv, 3740int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,