mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-06 14:45:14 +00:00
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>
This commit is contained in:
parent
b88935bf98
commit
0424c54897
1 changed files with 1 additions and 8 deletions
|
@ -4112,13 +4112,9 @@ static int may_commit_transaction(struct btrfs_root *root,
|
||||||
goto commit;
|
goto commit;
|
||||||
|
|
||||||
/* See if there is enough pinned space to make this reservation */
|
/* See if there is enough pinned space to make this reservation */
|
||||||
spin_lock(&space_info->lock);
|
|
||||||
if (percpu_counter_compare(&space_info->total_bytes_pinned,
|
if (percpu_counter_compare(&space_info->total_bytes_pinned,
|
||||||
bytes) >= 0) {
|
bytes) >= 0)
|
||||||
spin_unlock(&space_info->lock);
|
|
||||||
goto commit;
|
goto commit;
|
||||||
}
|
|
||||||
spin_unlock(&space_info->lock);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if there is some space in the delayed insertion reservation for
|
* 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,
|
||||||
if (space_info != delayed_rsv->space_info)
|
if (space_info != delayed_rsv->space_info)
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
|
||||||
spin_lock(&space_info->lock);
|
|
||||||
spin_lock(&delayed_rsv->lock);
|
spin_lock(&delayed_rsv->lock);
|
||||||
if (percpu_counter_compare(&space_info->total_bytes_pinned,
|
if (percpu_counter_compare(&space_info->total_bytes_pinned,
|
||||||
bytes - delayed_rsv->size) >= 0) {
|
bytes - delayed_rsv->size) >= 0) {
|
||||||
spin_unlock(&delayed_rsv->lock);
|
spin_unlock(&delayed_rsv->lock);
|
||||||
spin_unlock(&space_info->lock);
|
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
spin_unlock(&delayed_rsv->lock);
|
spin_unlock(&delayed_rsv->lock);
|
||||||
spin_unlock(&space_info->lock);
|
|
||||||
|
|
||||||
commit:
|
commit:
|
||||||
trans = btrfs_join_transaction(root);
|
trans = btrfs_join_transaction(root);
|
||||||
|
|
Loading…
Add table
Reference in a new issue