diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-03-06 00:54:59 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fb.com> | 2014-03-10 15:17:25 -0400 |
commit | 0424c548976b4c2a72c0bdbea425cf9d51e82d0f (patch) | |
tree | c2b23a67f9f423969676d4f5ec8fc5836d48d2ea /fs/btrfs/extent-tree.c | |
parent | b88935bf9822cda58fd70dffe8e016d448757d40 (diff) |
Btrfs: remove unnecessary lock in may_commit_transaction()
The reason is:
- The per-cpu counter has its own lock to protect itself.
- Here we needn't get a exact value.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 6b821c64b37b..5608b4f8a27e 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4112,13 +4112,9 @@ static int may_commit_transaction(struct btrfs_root *root, | |||
4112 | goto commit; | 4112 | goto commit; |
4113 | 4113 | ||
4114 | /* See if there is enough pinned space to make this reservation */ | 4114 | /* See if there is enough pinned space to make this reservation */ |
4115 | spin_lock(&space_info->lock); | ||
4116 | if (percpu_counter_compare(&space_info->total_bytes_pinned, | 4115 | if (percpu_counter_compare(&space_info->total_bytes_pinned, |
4117 | bytes) >= 0) { | 4116 | bytes) >= 0) |
4118 | spin_unlock(&space_info->lock); | ||
4119 | goto commit; | 4117 | goto commit; |
4120 | } | ||
4121 | spin_unlock(&space_info->lock); | ||
4122 | 4118 | ||
4123 | /* | 4119 | /* |
4124 | * See if there is some space in the delayed insertion reservation for | 4120 | * See if there is some space in the delayed insertion reservation for |
@@ -4127,16 +4123,13 @@ static int may_commit_transaction(struct btrfs_root *root, | |||
4127 | if (space_info != delayed_rsv->space_info) | 4123 | if (space_info != delayed_rsv->space_info) |
4128 | return -ENOSPC; | 4124 | return -ENOSPC; |
4129 | 4125 | ||
4130 | spin_lock(&space_info->lock); | ||
4131 | spin_lock(&delayed_rsv->lock); | 4126 | spin_lock(&delayed_rsv->lock); |
4132 | if (percpu_counter_compare(&space_info->total_bytes_pinned, | 4127 | if (percpu_counter_compare(&space_info->total_bytes_pinned, |
4133 | bytes - delayed_rsv->size) >= 0) { | 4128 | bytes - delayed_rsv->size) >= 0) { |
4134 | spin_unlock(&delayed_rsv->lock); | 4129 | spin_unlock(&delayed_rsv->lock); |
4135 | spin_unlock(&space_info->lock); | ||
4136 | return -ENOSPC; | 4130 | return -ENOSPC; |
4137 | } | 4131 | } |
4138 | spin_unlock(&delayed_rsv->lock); | 4132 | spin_unlock(&delayed_rsv->lock); |
4139 | spin_unlock(&space_info->lock); | ||
4140 | 4133 | ||
4141 | commit: | 4134 | commit: |
4142 | trans = btrfs_join_transaction(root); | 4135 | trans = btrfs_join_transaction(root); |