struct btrfs_block_group *cache,
u64 bytenr, u64 num_bytes, int reserved)
{
+ const u64 reserved_bytes = (reserved ? num_bytes : 0);
+
spin_lock(&cache->space_info->lock);
spin_lock(&cache->lock);
cache->pinned += num_bytes;
- btrfs_space_info_update_bytes_pinned(cache->space_info, num_bytes);
- if (reserved) {
- cache->reserved -= num_bytes;
- cache->space_info->bytes_reserved -= num_bytes;
- }
+ cache->reserved -= reserved_bytes;
spin_unlock(&cache->lock);
+ cache->space_info->bytes_reserved -= reserved_bytes;
+ btrfs_space_info_update_bytes_pinned(cache->space_info, num_bytes);
spin_unlock(&cache->space_info->lock);
btrfs_set_extent_bit(&trans->transaction->pinned_extents, bytenr,