Skip to content

Commit 1eab35c

Browse files
fdmananakdave
authored andcommitted
btrfs: collapse unaccount_log_buffer() into clean_log_buffer()
There's one only one caller of unaccount_log_buffer() and both this function and the caller are short, so move its code into the caller. Reviewed-by: Boris Burkov <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]>
1 parent 79072dc commit 1eab35c

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

fs/btrfs/tree-log.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,52 +2724,43 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
27242724
return ret;
27252725
}
27262726

2727-
/*
2728-
* Correctly adjust the reserved bytes occupied by a log tree extent buffer
2729-
*/
2730-
static int unaccount_log_buffer(struct btrfs_fs_info *fs_info, u64 start)
2731-
{
2732-
struct btrfs_block_group *cache;
2733-
2734-
cache = btrfs_lookup_block_group(fs_info, start);
2735-
if (!cache) {
2736-
btrfs_err(fs_info, "unable to find block group for %llu", start);
2737-
return -ENOENT;
2738-
}
2739-
2740-
spin_lock(&cache->space_info->lock);
2741-
spin_lock(&cache->lock);
2742-
cache->reserved -= fs_info->nodesize;
2743-
cache->space_info->bytes_reserved -= fs_info->nodesize;
2744-
spin_unlock(&cache->lock);
2745-
spin_unlock(&cache->space_info->lock);
2746-
2747-
btrfs_put_block_group(cache);
2748-
2749-
return 0;
2750-
}
2751-
27522727
static int clean_log_buffer(struct btrfs_trans_handle *trans,
27532728
struct extent_buffer *eb)
27542729
{
2755-
int ret;
2730+
struct btrfs_fs_info *fs_info = eb->fs_info;
2731+
struct btrfs_block_group *bg;
27562732

27572733
btrfs_tree_lock(eb);
27582734
btrfs_clear_buffer_dirty(trans, eb);
27592735
wait_on_extent_buffer_writeback(eb);
27602736
btrfs_tree_unlock(eb);
27612737

27622738
if (trans) {
2739+
int ret;
2740+
27632741
ret = btrfs_pin_reserved_extent(trans, eb);
27642742
if (ret)
27652743
btrfs_abort_transaction(trans, ret);
27662744
return ret;
27672745
}
27682746

2769-
ret = unaccount_log_buffer(eb->fs_info, eb->start);
2770-
if (ret)
2771-
btrfs_handle_fs_error(eb->fs_info, ret, NULL);
2772-
return ret;
2747+
bg = btrfs_lookup_block_group(fs_info, eb->start);
2748+
if (!bg) {
2749+
btrfs_err(fs_info, "unable to find block group for %llu", eb->start);
2750+
btrfs_handle_fs_error(fs_info, -ENOENT, NULL);
2751+
return -ENOENT;
2752+
}
2753+
2754+
spin_lock(&bg->space_info->lock);
2755+
spin_lock(&bg->lock);
2756+
bg->reserved -= fs_info->nodesize;
2757+
bg->space_info->bytes_reserved -= fs_info->nodesize;
2758+
spin_unlock(&bg->lock);
2759+
spin_unlock(&bg->space_info->lock);
2760+
2761+
btrfs_put_block_group(bg);
2762+
2763+
return 0;
27732764
}
27742765

27752766
static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,

0 commit comments

Comments
 (0)