Commit 28f0779a authored by David Sterba's avatar David Sterba

btrfs tests: replace whole ops structure for free space tests

Preparatory work for making btrfs_free_space_op constant. In
test_steal_space_from_bitmap_to_extent, we substitute use_bitmap with
own version thus preventing constification. We can rework it so we
replace the whole structure with the correct function pointers.
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 100d5702
...@@ -445,9 +445,11 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache) ...@@ -445,9 +445,11 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
int ret; int ret;
u64 offset; u64 offset;
u64 max_extent_size; u64 max_extent_size;
struct btrfs_free_space_op test_free_space_ops = {
bool (*use_bitmap_op)(struct btrfs_free_space_ctl *, .recalc_thresholds = cache->free_space_ctl->op->recalc_thresholds,
struct btrfs_free_space *); .use_bitmap = test_use_bitmap,
};
struct btrfs_free_space_op *orig_free_space_ops;
test_msg("Running space stealing from bitmap to extent\n"); test_msg("Running space stealing from bitmap to extent\n");
...@@ -469,8 +471,8 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache) ...@@ -469,8 +471,8 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
* that forces use of bitmaps as soon as we have at least 1 * that forces use of bitmaps as soon as we have at least 1
* extent entry. * extent entry.
*/ */
use_bitmap_op = cache->free_space_ctl->op->use_bitmap; orig_free_space_ops = cache->free_space_ctl->op;
cache->free_space_ctl->op->use_bitmap = test_use_bitmap; cache->free_space_ctl->op = &test_free_space_ops;
/* /*
* Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[ * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
...@@ -877,7 +879,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache) ...@@ -877,7 +879,7 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
if (ret) if (ret)
return ret; return ret;
cache->free_space_ctl->op->use_bitmap = use_bitmap_op; cache->free_space_ctl->op = orig_free_space_ops;
__btrfs_remove_free_space_cache(cache->free_space_ctl); __btrfs_remove_free_space_cache(cache->free_space_ctl);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment