Skip to content

Commit df384da

Browse files
josefbacikkdave
authored andcommitted
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 <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Anand Jain <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent bf1f1fe commit df384da

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

fs/btrfs/block-group.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,13 +3476,15 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
34763476
spin_unlock(&info->delalloc_root_lock);
34773477

34783478
while (total) {
3479+
struct btrfs_space_info *space_info;
34793480
bool reclaim = false;
34803481

34813482
cache = btrfs_lookup_block_group(info, bytenr);
34823483
if (!cache) {
34833484
ret = -ENOENT;
34843485
break;
34853486
}
3487+
space_info = cache->space_info;
34863488
factor = btrfs_bg_type_to_factor(cache->flags);
34873489

34883490
/*
@@ -3497,7 +3499,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
34973499
byte_in_group = bytenr - cache->start;
34983500
WARN_ON(byte_in_group > cache->length);
34993501

3500-
spin_lock(&cache->space_info->lock);
3502+
spin_lock(&space_info->lock);
35013503
spin_lock(&cache->lock);
35023504

35033505
if (btrfs_test_opt(info, SPACE_CACHE) &&
@@ -3510,24 +3512,24 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
35103512
old_val += num_bytes;
35113513
cache->used = old_val;
35123514
cache->reserved -= num_bytes;
3513-
cache->space_info->bytes_reserved -= num_bytes;
3514-
cache->space_info->bytes_used += num_bytes;
3515-
cache->space_info->disk_used += num_bytes * factor;
3515+
space_info->bytes_reserved -= num_bytes;
3516+
space_info->bytes_used += num_bytes;
3517+
space_info->disk_used += num_bytes * factor;
35163518
spin_unlock(&cache->lock);
3517-
spin_unlock(&cache->space_info->lock);
3519+
spin_unlock(&space_info->lock);
35183520
} else {
35193521
old_val -= num_bytes;
35203522
cache->used = old_val;
35213523
cache->pinned += num_bytes;
3522-
btrfs_space_info_update_bytes_pinned(info,
3523-
cache->space_info, num_bytes);
3524-
cache->space_info->bytes_used -= num_bytes;
3525-
cache->space_info->disk_used -= num_bytes * factor;
3524+
btrfs_space_info_update_bytes_pinned(info, space_info,
3525+
num_bytes);
3526+
space_info->bytes_used -= num_bytes;
3527+
space_info->disk_used -= num_bytes * factor;
35263528

35273529
reclaim = should_reclaim_block_group(cache, num_bytes);
35283530

35293531
spin_unlock(&cache->lock);
3530-
spin_unlock(&cache->space_info->lock);
3532+
spin_unlock(&space_info->lock);
35313533

35323534
set_extent_dirty(&trans->transaction->pinned_extents,
35333535
bytenr, bytenr + num_bytes - 1,

0 commit comments

Comments
 (0)