1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2013 Fusion IO. All rights reserved.
6 #include <linux/slab.h>
7 #include "btrfs-tests.h"
9 #include "../disk-io.h"
10 #include "../free-space-cache.h"
12 #define BITS_PER_BITMAP (PAGE_SIZE * 8UL)
15 * This test just does basic sanity checking, making sure we can add an extent
16 * entry and remove space from either end and the middle, and make sure we can
17 * remove space that covers adjacent extent entries.
19 static int test_extents(struct btrfs_block_group_cache
*cache
)
23 test_msg("Running extent only tests\n");
25 /* First just make sure we can remove an entire entry */
26 ret
= btrfs_add_free_space(cache
, 0, SZ_4M
);
28 test_msg("Error adding initial extents %d\n", ret
);
32 ret
= btrfs_remove_free_space(cache
, 0, SZ_4M
);
34 test_msg("Error removing extent %d\n", ret
);
38 if (test_check_exists(cache
, 0, SZ_4M
)) {
39 test_msg("Full remove left some lingering space\n");
43 /* Ok edge and middle cases now */
44 ret
= btrfs_add_free_space(cache
, 0, SZ_4M
);
46 test_msg("Error adding half extent %d\n", ret
);
50 ret
= btrfs_remove_free_space(cache
, 3 * SZ_1M
, SZ_1M
);
52 test_msg("Error removing tail end %d\n", ret
);
56 ret
= btrfs_remove_free_space(cache
, 0, SZ_1M
);
58 test_msg("Error removing front end %d\n", ret
);
62 ret
= btrfs_remove_free_space(cache
, SZ_2M
, 4096);
64 test_msg("Error removing middle piece %d\n", ret
);
68 if (test_check_exists(cache
, 0, SZ_1M
)) {
69 test_msg("Still have space at the front\n");
73 if (test_check_exists(cache
, SZ_2M
, 4096)) {
74 test_msg("Still have space in the middle\n");
78 if (test_check_exists(cache
, 3 * SZ_1M
, SZ_1M
)) {
79 test_msg("Still have space at the end\n");
84 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
89 static int test_bitmaps(struct btrfs_block_group_cache
*cache
,
92 u64 next_bitmap_offset
;
95 test_msg("Running bitmap only tests\n");
97 ret
= test_add_free_space_entry(cache
, 0, SZ_4M
, 1);
99 test_msg("Couldn't create a bitmap entry %d\n", ret
);
103 ret
= btrfs_remove_free_space(cache
, 0, SZ_4M
);
105 test_msg("Error removing bitmap full range %d\n", ret
);
109 if (test_check_exists(cache
, 0, SZ_4M
)) {
110 test_msg("Left some space in bitmap\n");
114 ret
= test_add_free_space_entry(cache
, 0, SZ_4M
, 1);
116 test_msg("Couldn't add to our bitmap entry %d\n", ret
);
120 ret
= btrfs_remove_free_space(cache
, SZ_1M
, SZ_2M
);
122 test_msg("Couldn't remove middle chunk %d\n", ret
);
127 * The first bitmap we have starts at offset 0 so the next one is just
128 * at the end of the first bitmap.
130 next_bitmap_offset
= (u64
)(BITS_PER_BITMAP
* sectorsize
);
132 /* Test a bit straddling two bitmaps */
133 ret
= test_add_free_space_entry(cache
, next_bitmap_offset
- SZ_2M
,
136 test_msg("Couldn't add space that straddles two bitmaps %d\n",
141 ret
= btrfs_remove_free_space(cache
, next_bitmap_offset
- SZ_1M
, SZ_2M
);
143 test_msg("Couldn't remove overlapping space %d\n", ret
);
147 if (test_check_exists(cache
, next_bitmap_offset
- SZ_1M
, SZ_2M
)) {
148 test_msg("Left some space when removing overlapping\n");
152 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
157 /* This is the high grade jackassery */
158 static int test_bitmaps_and_extents(struct btrfs_block_group_cache
*cache
,
161 u64 bitmap_offset
= (u64
)(BITS_PER_BITMAP
* sectorsize
);
164 test_msg("Running bitmap and extent tests\n");
167 * First let's do something simple, an extent at the same offset as the
168 * bitmap, but the free space completely in the extent and then
169 * completely in the bitmap.
171 ret
= test_add_free_space_entry(cache
, SZ_4M
, SZ_1M
, 1);
173 test_msg("Couldn't create bitmap entry %d\n", ret
);
177 ret
= test_add_free_space_entry(cache
, 0, SZ_1M
, 0);
179 test_msg("Couldn't add extent entry %d\n", ret
);
183 ret
= btrfs_remove_free_space(cache
, 0, SZ_1M
);
185 test_msg("Couldn't remove extent entry %d\n", ret
);
189 if (test_check_exists(cache
, 0, SZ_1M
)) {
190 test_msg("Left remnants after our remove\n");
194 /* Now to add back the extent entry and remove from the bitmap */
195 ret
= test_add_free_space_entry(cache
, 0, SZ_1M
, 0);
197 test_msg("Couldn't re-add extent entry %d\n", ret
);
201 ret
= btrfs_remove_free_space(cache
, SZ_4M
, SZ_1M
);
203 test_msg("Couldn't remove from bitmap %d\n", ret
);
207 if (test_check_exists(cache
, SZ_4M
, SZ_1M
)) {
208 test_msg("Left remnants in the bitmap\n");
213 * Ok so a little more evil, extent entry and bitmap at the same offset,
214 * removing an overlapping chunk.
216 ret
= test_add_free_space_entry(cache
, SZ_1M
, SZ_4M
, 1);
218 test_msg("Couldn't add to a bitmap %d\n", ret
);
222 ret
= btrfs_remove_free_space(cache
, SZ_512K
, 3 * SZ_1M
);
224 test_msg("Couldn't remove overlapping space %d\n", ret
);
228 if (test_check_exists(cache
, SZ_512K
, 3 * SZ_1M
)) {
229 test_msg("Left over pieces after removing overlapping\n");
233 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
235 /* Now with the extent entry offset into the bitmap */
236 ret
= test_add_free_space_entry(cache
, SZ_4M
, SZ_4M
, 1);
238 test_msg("Couldn't add space to the bitmap %d\n", ret
);
242 ret
= test_add_free_space_entry(cache
, SZ_2M
, SZ_2M
, 0);
244 test_msg("Couldn't add extent to the cache %d\n", ret
);
248 ret
= btrfs_remove_free_space(cache
, 3 * SZ_1M
, SZ_4M
);
250 test_msg("Problem removing overlapping space %d\n", ret
);
254 if (test_check_exists(cache
, 3 * SZ_1M
, SZ_4M
)) {
255 test_msg("Left something behind when removing space");
260 * This has blown up in the past, the extent entry starts before the
261 * bitmap entry, but we're trying to remove an offset that falls
262 * completely within the bitmap range and is in both the extent entry
263 * and the bitmap entry, looks like this
269 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
270 ret
= test_add_free_space_entry(cache
, bitmap_offset
+ SZ_4M
, SZ_4M
, 1);
272 test_msg("Couldn't add bitmap %d\n", ret
);
276 ret
= test_add_free_space_entry(cache
, bitmap_offset
- SZ_1M
,
279 test_msg("Couldn't add extent entry %d\n", ret
);
283 ret
= btrfs_remove_free_space(cache
, bitmap_offset
+ SZ_1M
, 5 * SZ_1M
);
285 test_msg("Failed to free our space %d\n", ret
);
289 if (test_check_exists(cache
, bitmap_offset
+ SZ_1M
, 5 * SZ_1M
)) {
290 test_msg("Left stuff over\n");
294 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
297 * This blew up before, we have part of the free space in a bitmap and
298 * then the entirety of the rest of the space in an extent. This used
299 * to return -EAGAIN back from btrfs_remove_extent, make sure this
302 ret
= test_add_free_space_entry(cache
, SZ_1M
, SZ_2M
, 1);
304 test_msg("Couldn't add bitmap entry %d\n", ret
);
308 ret
= test_add_free_space_entry(cache
, 3 * SZ_1M
, SZ_1M
, 0);
310 test_msg("Couldn't add extent entry %d\n", ret
);
314 ret
= btrfs_remove_free_space(cache
, SZ_1M
, 3 * SZ_1M
);
316 test_msg("Error removing bitmap and extent overlapping %d\n", ret
);
320 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
324 /* Used by test_steal_space_from_bitmap_to_extent(). */
325 static bool test_use_bitmap(struct btrfs_free_space_ctl
*ctl
,
326 struct btrfs_free_space
*info
)
328 return ctl
->free_extents
> 0;
331 /* Used by test_steal_space_from_bitmap_to_extent(). */
333 check_num_extents_and_bitmaps(const struct btrfs_block_group_cache
*cache
,
334 const int num_extents
,
335 const int num_bitmaps
)
337 if (cache
->free_space_ctl
->free_extents
!= num_extents
) {
338 test_msg("Incorrect # of extent entries in the cache: %d, expected %d\n",
339 cache
->free_space_ctl
->free_extents
, num_extents
);
342 if (cache
->free_space_ctl
->total_bitmaps
!= num_bitmaps
) {
343 test_msg("Incorrect # of extent entries in the cache: %d, expected %d\n",
344 cache
->free_space_ctl
->total_bitmaps
, num_bitmaps
);
350 /* Used by test_steal_space_from_bitmap_to_extent(). */
351 static int check_cache_empty(struct btrfs_block_group_cache
*cache
)
357 * Now lets confirm that there's absolutely no free space left to
360 if (cache
->free_space_ctl
->free_space
!= 0) {
361 test_msg("Cache free space is not 0\n");
365 /* And any allocation request, no matter how small, should fail now. */
366 offset
= btrfs_find_space_for_alloc(cache
, 0, 4096, 0,
369 test_msg("Space allocation did not fail, returned offset: %llu",
374 /* And no extent nor bitmap entries in the cache anymore. */
375 return check_num_extents_and_bitmaps(cache
, 0, 0);
379 * Before we were able to steal free space from a bitmap entry to an extent
380 * entry, we could end up with 2 entries representing a contiguous free space.
381 * One would be an extent entry and the other a bitmap entry. Since in order
382 * to allocate space to a caller we use only 1 entry, we couldn't return that
383 * whole range to the caller if it was requested. This forced the caller to
384 * either assume ENOSPC or perform several smaller space allocations, which
385 * wasn't optimal as they could be spread all over the block group while under
386 * concurrency (extra overhead and fragmentation).
388 * This stealing approach is beneficial, since we always prefer to allocate
389 * from extent entries, both for clustered and non-clustered allocation
393 test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache
*cache
,
399 const struct btrfs_free_space_op test_free_space_ops
= {
400 .recalc_thresholds
= cache
->free_space_ctl
->op
->recalc_thresholds
,
401 .use_bitmap
= test_use_bitmap
,
403 const struct btrfs_free_space_op
*orig_free_space_ops
;
405 test_msg("Running space stealing from bitmap to extent\n");
408 * For this test, we want to ensure we end up with an extent entry
409 * immediately adjacent to a bitmap entry, where the bitmap starts
410 * at an offset where the extent entry ends. We keep adding and
411 * removing free space to reach into this state, but to get there
412 * we need to reach a point where marking new free space doesn't
413 * result in adding new extent entries or merging the new space
414 * with existing extent entries - the space ends up being marked
415 * in an existing bitmap that covers the new free space range.
417 * To get there, we need to reach the threshold defined set at
418 * cache->free_space_ctl->extents_thresh, which currently is
419 * 256 extents on a x86_64 system at least, and a few other
420 * conditions (check free_space_cache.c). Instead of making the
421 * test much longer and complicated, use a "use_bitmap" operation
422 * that forces use of bitmaps as soon as we have at least 1
425 orig_free_space_ops
= cache
->free_space_ctl
->op
;
426 cache
->free_space_ctl
->op
= &test_free_space_ops
;
429 * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
431 ret
= test_add_free_space_entry(cache
, SZ_128M
- SZ_256K
, SZ_128K
, 0);
433 test_msg("Couldn't add extent entry %d\n", ret
);
437 /* Bitmap entry covering free space range [128Mb + 512Kb, 256Mb[ */
438 ret
= test_add_free_space_entry(cache
, SZ_128M
+ SZ_512K
,
439 SZ_128M
- SZ_512K
, 1);
441 test_msg("Couldn't add bitmap entry %d\n", ret
);
445 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
450 * Now make only the first 256Kb of the bitmap marked as free, so that
451 * we end up with only the following ranges marked as free space:
453 * [128Mb - 256Kb, 128Mb - 128Kb[
454 * [128Mb + 512Kb, 128Mb + 768Kb[
456 ret
= btrfs_remove_free_space(cache
,
457 SZ_128M
+ 768 * SZ_1K
,
458 SZ_128M
- 768 * SZ_1K
);
460 test_msg("Failed to free part of bitmap space %d\n", ret
);
464 /* Confirm that only those 2 ranges are marked as free. */
465 if (!test_check_exists(cache
, SZ_128M
- SZ_256K
, SZ_128K
)) {
466 test_msg("Free space range missing\n");
469 if (!test_check_exists(cache
, SZ_128M
+ SZ_512K
, SZ_256K
)) {
470 test_msg("Free space range missing\n");
475 * Confirm that the bitmap range [128Mb + 768Kb, 256Mb[ isn't marked
478 if (test_check_exists(cache
, SZ_128M
+ 768 * SZ_1K
,
479 SZ_128M
- 768 * SZ_1K
)) {
480 test_msg("Bitmap region not removed from space cache\n");
485 * Confirm that the region [128Mb + 256Kb, 128Mb + 512Kb[, which is
486 * covered by the bitmap, isn't marked as free.
488 if (test_check_exists(cache
, SZ_128M
+ SZ_256K
, SZ_256K
)) {
489 test_msg("Invalid bitmap region marked as free\n");
494 * Confirm that the region [128Mb, 128Mb + 256Kb[, which is covered
495 * by the bitmap too, isn't marked as free either.
497 if (test_check_exists(cache
, SZ_128M
, SZ_256K
)) {
498 test_msg("Invalid bitmap region marked as free\n");
503 * Now lets mark the region [128Mb, 128Mb + 512Kb[ as free too. But,
504 * lets make sure the free space cache marks it as free in the bitmap,
505 * and doesn't insert a new extent entry to represent this region.
507 ret
= btrfs_add_free_space(cache
, SZ_128M
, SZ_512K
);
509 test_msg("Error adding free space: %d\n", ret
);
512 /* Confirm the region is marked as free. */
513 if (!test_check_exists(cache
, SZ_128M
, SZ_512K
)) {
514 test_msg("Bitmap region not marked as free\n");
519 * Confirm that no new extent entries or bitmap entries were added to
520 * the cache after adding that free space region.
522 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
527 * Now lets add a small free space region to the right of the previous
528 * one, which is not contiguous with it and is part of the bitmap too.
529 * The goal is to test that the bitmap entry space stealing doesn't
530 * steal this space region.
532 ret
= btrfs_add_free_space(cache
, SZ_128M
+ SZ_16M
, sectorsize
);
534 test_msg("Error adding free space: %d\n", ret
);
539 * Confirm that no new extent entries or bitmap entries were added to
540 * the cache after adding that free space region.
542 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
547 * Now mark the region [128Mb - 128Kb, 128Mb[ as free too. This will
548 * expand the range covered by the existing extent entry that represents
549 * the free space [128Mb - 256Kb, 128Mb - 128Kb[.
551 ret
= btrfs_add_free_space(cache
, SZ_128M
- SZ_128K
, SZ_128K
);
553 test_msg("Error adding free space: %d\n", ret
);
556 /* Confirm the region is marked as free. */
557 if (!test_check_exists(cache
, SZ_128M
- SZ_128K
, SZ_128K
)) {
558 test_msg("Extent region not marked as free\n");
563 * Confirm that our extent entry didn't stole all free space from the
564 * bitmap, because of the small 4Kb free space region.
566 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
571 * So now we have the range [128Mb - 256Kb, 128Mb + 768Kb[ as free
572 * space. Without stealing bitmap free space into extent entry space,
573 * we would have all this free space represented by 2 entries in the
576 * extent entry covering range: [128Mb - 256Kb, 128Mb[
577 * bitmap entry covering range: [128Mb, 128Mb + 768Kb[
579 * Attempting to allocate the whole free space (1Mb) would fail, because
580 * we can't allocate from multiple entries.
581 * With the bitmap free space stealing, we get a single extent entry
582 * that represents the 1Mb free space, and therefore we're able to
583 * allocate the whole free space at once.
585 if (!test_check_exists(cache
, SZ_128M
- SZ_256K
, SZ_1M
)) {
586 test_msg("Expected region not marked as free\n");
590 if (cache
->free_space_ctl
->free_space
!= (SZ_1M
+ sectorsize
)) {
591 test_msg("Cache free space is not 1Mb + %u\n", sectorsize
);
595 offset
= btrfs_find_space_for_alloc(cache
,
598 if (offset
!= (SZ_128M
- SZ_256K
)) {
599 test_msg("Failed to allocate 1Mb from space cache, returned offset is: %llu\n",
605 * All that remains is a sectorsize free space region in a bitmap.
608 ret
= check_num_extents_and_bitmaps(cache
, 1, 1);
612 if (cache
->free_space_ctl
->free_space
!= sectorsize
) {
613 test_msg("Cache free space is not %u\n", sectorsize
);
617 offset
= btrfs_find_space_for_alloc(cache
,
620 if (offset
!= (SZ_128M
+ SZ_16M
)) {
621 test_msg("Failed to allocate %u, returned offset : %llu\n",
626 ret
= check_cache_empty(cache
);
630 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
633 * Now test a similar scenario, but where our extent entry is located
634 * to the right of the bitmap entry, so that we can check that stealing
635 * space from a bitmap to the front of an extent entry works.
639 * Extent entry covering free space range [128Mb + 128Kb, 128Mb + 256Kb[
641 ret
= test_add_free_space_entry(cache
, SZ_128M
+ SZ_128K
, SZ_128K
, 0);
643 test_msg("Couldn't add extent entry %d\n", ret
);
647 /* Bitmap entry covering free space range [0, 128Mb - 512Kb[ */
648 ret
= test_add_free_space_entry(cache
, 0, SZ_128M
- SZ_512K
, 1);
650 test_msg("Couldn't add bitmap entry %d\n", ret
);
654 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
659 * Now make only the last 256Kb of the bitmap marked as free, so that
660 * we end up with only the following ranges marked as free space:
662 * [128Mb + 128b, 128Mb + 256Kb[
663 * [128Mb - 768Kb, 128Mb - 512Kb[
665 ret
= btrfs_remove_free_space(cache
, 0, SZ_128M
- 768 * SZ_1K
);
667 test_msg("Failed to free part of bitmap space %d\n", ret
);
671 /* Confirm that only those 2 ranges are marked as free. */
672 if (!test_check_exists(cache
, SZ_128M
+ SZ_128K
, SZ_128K
)) {
673 test_msg("Free space range missing\n");
676 if (!test_check_exists(cache
, SZ_128M
- 768 * SZ_1K
, SZ_256K
)) {
677 test_msg("Free space range missing\n");
682 * Confirm that the bitmap range [0, 128Mb - 768Kb[ isn't marked
685 if (test_check_exists(cache
, 0, SZ_128M
- 768 * SZ_1K
)) {
686 test_msg("Bitmap region not removed from space cache\n");
691 * Confirm that the region [128Mb - 512Kb, 128Mb[, which is
692 * covered by the bitmap, isn't marked as free.
694 if (test_check_exists(cache
, SZ_128M
- SZ_512K
, SZ_512K
)) {
695 test_msg("Invalid bitmap region marked as free\n");
700 * Now lets mark the region [128Mb - 512Kb, 128Mb[ as free too. But,
701 * lets make sure the free space cache marks it as free in the bitmap,
702 * and doesn't insert a new extent entry to represent this region.
704 ret
= btrfs_add_free_space(cache
, SZ_128M
- SZ_512K
, SZ_512K
);
706 test_msg("Error adding free space: %d\n", ret
);
709 /* Confirm the region is marked as free. */
710 if (!test_check_exists(cache
, SZ_128M
- SZ_512K
, SZ_512K
)) {
711 test_msg("Bitmap region not marked as free\n");
716 * Confirm that no new extent entries or bitmap entries were added to
717 * the cache after adding that free space region.
719 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
724 * Now lets add a small free space region to the left of the previous
725 * one, which is not contiguous with it and is part of the bitmap too.
726 * The goal is to test that the bitmap entry space stealing doesn't
727 * steal this space region.
729 ret
= btrfs_add_free_space(cache
, SZ_32M
, 2 * sectorsize
);
731 test_msg("Error adding free space: %d\n", ret
);
736 * Now mark the region [128Mb, 128Mb + 128Kb[ as free too. This will
737 * expand the range covered by the existing extent entry that represents
738 * the free space [128Mb + 128Kb, 128Mb + 256Kb[.
740 ret
= btrfs_add_free_space(cache
, SZ_128M
, SZ_128K
);
742 test_msg("Error adding free space: %d\n", ret
);
745 /* Confirm the region is marked as free. */
746 if (!test_check_exists(cache
, SZ_128M
, SZ_128K
)) {
747 test_msg("Extent region not marked as free\n");
752 * Confirm that our extent entry didn't stole all free space from the
753 * bitmap, because of the small 2 * sectorsize free space region.
755 ret
= check_num_extents_and_bitmaps(cache
, 2, 1);
760 * So now we have the range [128Mb - 768Kb, 128Mb + 256Kb[ as free
761 * space. Without stealing bitmap free space into extent entry space,
762 * we would have all this free space represented by 2 entries in the
765 * extent entry covering range: [128Mb, 128Mb + 256Kb[
766 * bitmap entry covering range: [128Mb - 768Kb, 128Mb[
768 * Attempting to allocate the whole free space (1Mb) would fail, because
769 * we can't allocate from multiple entries.
770 * With the bitmap free space stealing, we get a single extent entry
771 * that represents the 1Mb free space, and therefore we're able to
772 * allocate the whole free space at once.
774 if (!test_check_exists(cache
, SZ_128M
- 768 * SZ_1K
, SZ_1M
)) {
775 test_msg("Expected region not marked as free\n");
779 if (cache
->free_space_ctl
->free_space
!= (SZ_1M
+ 2 * sectorsize
)) {
780 test_msg("Cache free space is not 1Mb + %u\n", 2 * sectorsize
);
784 offset
= btrfs_find_space_for_alloc(cache
, 0, SZ_1M
, 0,
786 if (offset
!= (SZ_128M
- 768 * SZ_1K
)) {
787 test_msg("Failed to allocate 1Mb from space cache, returned offset is: %llu\n",
793 * All that remains is 2 * sectorsize free space region
794 * in a bitmap. Confirm.
796 ret
= check_num_extents_and_bitmaps(cache
, 1, 1);
800 if (cache
->free_space_ctl
->free_space
!= 2 * sectorsize
) {
801 test_msg("Cache free space is not %u\n", 2 * sectorsize
);
805 offset
= btrfs_find_space_for_alloc(cache
,
806 0, 2 * sectorsize
, 0,
808 if (offset
!= SZ_32M
) {
809 test_msg("Failed to allocate %u, offset: %llu\n",
815 ret
= check_cache_empty(cache
);
819 cache
->free_space_ctl
->op
= orig_free_space_ops
;
820 __btrfs_remove_free_space_cache(cache
->free_space_ctl
);
825 int btrfs_test_free_space_cache(u32 sectorsize
, u32 nodesize
)
827 struct btrfs_fs_info
*fs_info
;
828 struct btrfs_block_group_cache
*cache
;
829 struct btrfs_root
*root
= NULL
;
832 test_msg("Running btrfs free space cache tests\n");
833 fs_info
= btrfs_alloc_dummy_fs_info(nodesize
, sectorsize
);
839 * For ppc64 (with 64k page size), bytes per bitmap might be
840 * larger than 1G. To make bitmap test available in ppc64,
841 * alloc dummy block group whose size cross bitmaps.
843 cache
= btrfs_alloc_dummy_block_group(fs_info
,
844 BITS_PER_BITMAP
* sectorsize
+ PAGE_SIZE
);
846 test_msg("Couldn't run the tests\n");
847 btrfs_free_dummy_fs_info(fs_info
);
851 root
= btrfs_alloc_dummy_root(fs_info
);
857 root
->fs_info
->extent_root
= root
;
859 ret
= test_extents(cache
);
862 ret
= test_bitmaps(cache
, sectorsize
);
865 ret
= test_bitmaps_and_extents(cache
, sectorsize
);
869 ret
= test_steal_space_from_bitmap_to_extent(cache
, sectorsize
);
871 btrfs_free_dummy_block_group(cache
);
872 btrfs_free_dummy_root(root
);
873 btrfs_free_dummy_fs_info(fs_info
);
874 test_msg("Free space cache tests finished\n");