diff options
author | Nikolay Borisov <nborisov@suse.com> | 2019-11-21 14:03:30 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-01-20 16:40:51 +0100 |
commit | 7ef54d54bf6aacb5faeb5a7f3db18b7828498099 (patch) | |
tree | 7e33b9d61cfc34479dc8d669150c04bfab80ca5f /fs/btrfs/extent-tree.c | |
parent | 4eaaec24c087a52c6b2ed75856037ae42cc6a830 (diff) |
btrfs: Open code __btrfs_free_reserved_extent in btrfs_free_reserved_extent
__btrfs_free_reserved_extent performs 2 entirely different operations
depending on whether its 'pin' argument is true or false. This patch
lifts the 2nd case (pin is false) into it's sole caller
btrfs_free_reserved_extent. No semantics changes.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 3495710c72b8..215dceaacaea 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4179,14 +4179,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, return -ENOSPC; } - if (pin) - pin_down_extent(cache, start, len, 1); - else { - btrfs_add_free_space(cache, start, len); - btrfs_free_reserved_bytes(cache, len, delalloc); - trace_btrfs_reserved_extent_free(fs_info, start, len); - } - + ret = pin_down_extent(cache, start, len, 1); btrfs_put_block_group(cache); return ret; } @@ -4194,7 +4187,20 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len, int delalloc) { - return __btrfs_free_reserved_extent(fs_info, start, len, 0, delalloc); + struct btrfs_block_group *cache; + + cache = btrfs_lookup_block_group(fs_info, start); + if (!cache) { + btrfs_err(fs_info, "unable to find block group for %llu", start); + return -ENOSPC; + } + + btrfs_add_free_space(cache, start, len); + btrfs_free_reserved_bytes(cache, len, delalloc); + trace_btrfs_reserved_extent_free(fs_info, start, len); + + btrfs_put_block_group(cache); + return 0; } int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info, |