mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
btrfs: use temporary variable for space_info in btrfs_update_block_group
We do cache->space_info->counter += num_bytes; everywhere in here. This is makes the lines longer than they need to be, and will be especially noticeable when we add the active tracking in, so add a temp variable for the space_info so this is cleaner. Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
bf1f1fec27
commit
df384da5a4
@@ -3476,6 +3476,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
|
|||||||
spin_unlock(&info->delalloc_root_lock);
|
spin_unlock(&info->delalloc_root_lock);
|
||||||
|
|
||||||
while (total) {
|
while (total) {
|
||||||
|
struct btrfs_space_info *space_info;
|
||||||
bool reclaim = false;
|
bool reclaim = false;
|
||||||
|
|
||||||
cache = btrfs_lookup_block_group(info, bytenr);
|
cache = btrfs_lookup_block_group(info, bytenr);
|
||||||
@@ -3483,6 +3484,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
|
|||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
space_info = cache->space_info;
|
||||||
factor = btrfs_bg_type_to_factor(cache->flags);
|
factor = btrfs_bg_type_to_factor(cache->flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3497,7 +3499,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
|
|||||||
byte_in_group = bytenr - cache->start;
|
byte_in_group = bytenr - cache->start;
|
||||||
WARN_ON(byte_in_group > cache->length);
|
WARN_ON(byte_in_group > cache->length);
|
||||||
|
|
||||||
spin_lock(&cache->space_info->lock);
|
spin_lock(&space_info->lock);
|
||||||
spin_lock(&cache->lock);
|
spin_lock(&cache->lock);
|
||||||
|
|
||||||
if (btrfs_test_opt(info, SPACE_CACHE) &&
|
if (btrfs_test_opt(info, SPACE_CACHE) &&
|
||||||
@@ -3510,24 +3512,24 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
|
|||||||
old_val += num_bytes;
|
old_val += num_bytes;
|
||||||
cache->used = old_val;
|
cache->used = old_val;
|
||||||
cache->reserved -= num_bytes;
|
cache->reserved -= num_bytes;
|
||||||
cache->space_info->bytes_reserved -= num_bytes;
|
space_info->bytes_reserved -= num_bytes;
|
||||||
cache->space_info->bytes_used += num_bytes;
|
space_info->bytes_used += num_bytes;
|
||||||
cache->space_info->disk_used += num_bytes * factor;
|
space_info->disk_used += num_bytes * factor;
|
||||||
spin_unlock(&cache->lock);
|
spin_unlock(&cache->lock);
|
||||||
spin_unlock(&cache->space_info->lock);
|
spin_unlock(&space_info->lock);
|
||||||
} else {
|
} else {
|
||||||
old_val -= num_bytes;
|
old_val -= num_bytes;
|
||||||
cache->used = old_val;
|
cache->used = old_val;
|
||||||
cache->pinned += num_bytes;
|
cache->pinned += num_bytes;
|
||||||
btrfs_space_info_update_bytes_pinned(info,
|
btrfs_space_info_update_bytes_pinned(info, space_info,
|
||||||
cache->space_info, num_bytes);
|
num_bytes);
|
||||||
cache->space_info->bytes_used -= num_bytes;
|
space_info->bytes_used -= num_bytes;
|
||||||
cache->space_info->disk_used -= num_bytes * factor;
|
space_info->disk_used -= num_bytes * factor;
|
||||||
|
|
||||||
reclaim = should_reclaim_block_group(cache, num_bytes);
|
reclaim = should_reclaim_block_group(cache, num_bytes);
|
||||||
|
|
||||||
spin_unlock(&cache->lock);
|
spin_unlock(&cache->lock);
|
||||||
spin_unlock(&cache->space_info->lock);
|
spin_unlock(&space_info->lock);
|
||||||
|
|
||||||
set_extent_dirty(&trans->transaction->pinned_extents,
|
set_extent_dirty(&trans->transaction->pinned_extents,
|
||||||
bytenr, bytenr + num_bytes - 1,
|
bytenr, bytenr + num_bytes - 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user