btrfs: get fs_info from block group in pin_down_extent
authorDavid Sterba <dsterba@suse.com>
Wed, 20 Mar 2019 11:12:32 +0000 (12:12 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:45 +0000 (19:02 +0200)
We can read fs_info from the block group cache structure and can drop it
from the parameters.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index 7a0f3e1519996b86e099125de0785e22023fa706..a8b0434641e501db0ad3d3b5af21eaad2c9ba858 100644 (file)
@@ -6392,10 +6392,11 @@ static u64 first_logical_byte(struct btrfs_fs_info *fs_info, u64 search_start)
        return bytenr;
 }
 
        return bytenr;
 }
 
-static int pin_down_extent(struct btrfs_fs_info *fs_info,
-                          struct btrfs_block_group_cache *cache,
+static int pin_down_extent(struct btrfs_block_group_cache *cache,
                           u64 bytenr, u64 num_bytes, int reserved)
 {
                           u64 bytenr, u64 num_bytes, int reserved)
 {
+       struct btrfs_fs_info *fs_info = cache->fs_info;
+
        spin_lock(&cache->space_info->lock);
        spin_lock(&cache->lock);
        cache->pinned += num_bytes;
        spin_lock(&cache->space_info->lock);
        spin_lock(&cache->lock);
        cache->pinned += num_bytes;
@@ -6427,7 +6428,7 @@ int btrfs_pin_extent(struct btrfs_fs_info *fs_info,
        cache = btrfs_lookup_block_group(fs_info, bytenr);
        BUG_ON(!cache); /* Logic error */
 
        cache = btrfs_lookup_block_group(fs_info, bytenr);
        BUG_ON(!cache); /* Logic error */
 
-       pin_down_extent(fs_info, cache, bytenr, num_bytes, reserved);
+       pin_down_extent(cache, bytenr, num_bytes, reserved);
 
        btrfs_put_block_group(cache);
        return 0;
 
        btrfs_put_block_group(cache);
        return 0;
@@ -6454,7 +6455,7 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_fs_info *fs_info,
         */
        cache_block_group(cache, 1);
 
         */
        cache_block_group(cache, 1);
 
-       pin_down_extent(fs_info, cache, bytenr, num_bytes, 0);
+       pin_down_extent(cache, bytenr, num_bytes, 0);
 
        /* remove us from the free space cache (if we're there at all) */
        ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
 
        /* remove us from the free space cache (if we're there at all) */
        ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
@@ -7206,8 +7207,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
                cache = btrfs_lookup_block_group(fs_info, buf->start);
 
                if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
                cache = btrfs_lookup_block_group(fs_info, buf->start);
 
                if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
-                       pin_down_extent(fs_info, cache, buf->start,
-                                       buf->len, 1);
+                       pin_down_extent(cache, buf->start, buf->len, 1);
                        btrfs_put_block_group(cache);
                        goto out;
                }
                        btrfs_put_block_group(cache);
                        goto out;
                }
@@ -8182,7 +8182,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
        }
 
        if (pin)
        }
 
        if (pin)
-               pin_down_extent(fs_info, cache, start, len, 1);
+               pin_down_extent(cache, start, len, 1);
        else {
                if (btrfs_test_opt(fs_info, DISCARD))
                        ret = btrfs_discard_extent(fs_info, start, len, NULL);
        else {
                if (btrfs_test_opt(fs_info, DISCARD))
                        ret = btrfs_discard_extent(fs_info, start, len, NULL);