]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: remove use btrfs_remove_free_space_cache instead of variant
authorJosef Bacik <josef@toxicpanda.com>
Mon, 8 Aug 2022 20:10:27 +0000 (16:10 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:58 +0000 (12:27 +0200)
We are calling __btrfs_remove_free_space_cache everywhere to cleanup the
block group free space, however we can just use
btrfs_remove_free_space_cache and pass in the block group in all of
these places.  Then we can remove __btrfs_remove_free_space_cache and
rename __btrfs_remove_free_space_cache_locked to
__btrfs_remove_free_space_cache.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.h
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/free-space-tests.c

index 151a45d31c041ed3c69f7d16aabed72a63f55c4e..53c44c52cb7964e788e8e6b316bec67ba0cc0688 100644 (file)
@@ -4110,7 +4110,7 @@ void btrfs_unfreeze_block_group(struct btrfs_block_group *block_group)
                 * tasks trimming this block group have left 1 entry each one.
                 * Free them if any.
                 */
-               __btrfs_remove_free_space_cache(block_group->free_space_ctl);
+               btrfs_remove_free_space_cache(block_group);
        }
 }
 
index f2a6dd0336231fd05c64225d35493d34539485ed..0c94bbb5dcd714c807b92ec4aedef0a61463a1f3 100644 (file)
@@ -48,8 +48,7 @@ static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
                              struct btrfs_free_space *info, u64 offset,
                              u64 bytes, bool update_stats);
 
-static void __btrfs_remove_free_space_cache_locked(
-                               struct btrfs_free_space_ctl *ctl)
+static void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl)
 {
        struct btrfs_free_space *info;
        struct rb_node *node;
@@ -898,12 +897,8 @@ out:
 free_cache:
        io_ctl_drop_pages(&io_ctl);
 
-       /*
-        * We need to call the _locked variant so we don't try to update the
-        * discard counters.
-        */
        spin_lock(&ctl->tree_lock);
-       __btrfs_remove_free_space_cache_locked(ctl);
+       __btrfs_remove_free_space_cache(ctl);
        spin_unlock(&ctl->tree_lock);
        goto out;
 }
@@ -3010,15 +3005,6 @@ static void __btrfs_return_cluster_to_free_space(
        btrfs_put_block_group(block_group);
 }
 
-void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl)
-{
-       spin_lock(&ctl->tree_lock);
-       __btrfs_remove_free_space_cache_locked(ctl);
-       if (ctl->block_group)
-               btrfs_discard_update_discardable(ctl->block_group);
-       spin_unlock(&ctl->tree_lock);
-}
-
 void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group)
 {
        struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
@@ -3036,7 +3022,7 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group)
 
                cond_resched_lock(&ctl->tree_lock);
        }
-       __btrfs_remove_free_space_cache_locked(ctl);
+       __btrfs_remove_free_space_cache(ctl);
        btrfs_discard_update_discardable(block_group);
        spin_unlock(&ctl->tree_lock);
 
index 15591b2998956cd7c819cfe8d29a0e611ceb341c..6d419ba53e954ffef3c70f31d03919ce29eb760e 100644 (file)
@@ -113,7 +113,6 @@ int btrfs_add_free_space_async_trimmed(struct btrfs_block_group *block_group,
                                       u64 bytenr, u64 size);
 int btrfs_remove_free_space(struct btrfs_block_group *block_group,
                            u64 bytenr, u64 size);
-void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl);
 void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group);
 bool btrfs_is_free_space_trimmed(struct btrfs_block_group *block_group);
 u64 btrfs_find_space_for_alloc(struct btrfs_block_group *block_group,
index cc9377cf56a33ff3375373d351f89327d194042e..9c478fa256f65cdaaf1771c10367b520d20478b8 100644 (file)
@@ -243,7 +243,7 @@ void btrfs_free_dummy_block_group(struct btrfs_block_group *cache)
 {
        if (!cache)
                return;
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        kfree(cache->free_space_ctl);
        kfree(cache);
 }
index 5930cdcae5cb699af626c48f9cea4d46b04e8a28..ebf68fcd2149de122f25013d44c45705257bd023 100644 (file)
@@ -82,7 +82,7 @@ static int test_extents(struct btrfs_block_group *cache)
        }
 
        /* Cleanup */
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        return 0;
 }
@@ -149,7 +149,7 @@ static int test_bitmaps(struct btrfs_block_group *cache, u32 sectorsize)
                return -1;
        }
 
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        return 0;
 }
@@ -230,7 +230,7 @@ static int test_bitmaps_and_extents(struct btrfs_block_group *cache,
                return -1;
        }
 
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        /* Now with the extent entry offset into the bitmap */
        ret = test_add_free_space_entry(cache, SZ_4M, SZ_4M, 1);
@@ -266,7 +266,7 @@ static int test_bitmaps_and_extents(struct btrfs_block_group *cache,
         *      [ bitmap ]
         *        [ del ]
         */
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        ret = test_add_free_space_entry(cache, bitmap_offset + SZ_4M, SZ_4M, 1);
        if (ret) {
                test_err("couldn't add bitmap %d", ret);
@@ -291,7 +291,7 @@ static int test_bitmaps_and_extents(struct btrfs_block_group *cache,
                return -1;
        }
 
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        /*
         * This blew up before, we have part of the free space in a bitmap and
@@ -317,7 +317,7 @@ static int test_bitmaps_and_extents(struct btrfs_block_group *cache,
                return ret;
        }
 
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        return 0;
 }
 
@@ -629,7 +629,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group *cache,
        if (ret)
                return ret;
 
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        /*
         * Now test a similar scenario, but where our extent entry is located
@@ -819,7 +819,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group *cache,
                return ret;
 
        cache->free_space_ctl->op = orig_free_space_ops;
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
 
        return 0;
 }
@@ -868,7 +868,7 @@ static int test_bytes_index(struct btrfs_block_group *cache, u32 sectorsize)
        }
 
        /* Now validate bitmaps do the correct thing. */
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        for (i = 0; i < 2; i++) {
                offset = i * BITS_PER_BITMAP * sectorsize;
                bytes = (i + 1) * SZ_1M;
@@ -891,7 +891,7 @@ static int test_bytes_index(struct btrfs_block_group *cache, u32 sectorsize)
        }
 
        /* Now validate bitmaps with different ->max_extent_size. */
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        orig_free_space_ops = cache->free_space_ctl->op;
        cache->free_space_ctl->op = &test_free_space_ops;
 
@@ -998,7 +998,7 @@ static int test_bytes_index(struct btrfs_block_group *cache, u32 sectorsize)
        }
 
        cache->free_space_ctl->op = orig_free_space_ops;
-       __btrfs_remove_free_space_cache(cache->free_space_ctl);
+       btrfs_remove_free_space_cache(cache);
        return 0;
 }