linux/fs/btrfs/tests/free-space-tests.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2013 Fusion IO.  All rights reserved.
 */

#include <linux/slab.h>
#include "btrfs-tests.h"
#include "../ctree.h"
#include "../disk-io.h"
#include "../free-space-cache.h"
#include "../block-group.h"

#define BITS_PER_BITMAP

/*
 * This test just does basic sanity checking, making sure we can add an extent
 * entry and remove space from either end and the middle, and make sure we can
 * remove space that covers adjacent extent entries.
 */
static int test_extents(struct btrfs_block_group *cache)
{}

static int test_bitmaps(struct btrfs_block_group *cache, u32 sectorsize)
{}

/* This is the high grade jackassery */
static int test_bitmaps_and_extents(struct btrfs_block_group *cache,
				    u32 sectorsize)
{}

/* Used by test_steal_space_from_bitmap_to_extent(). */
static bool test_use_bitmap(struct btrfs_free_space_ctl *ctl,
			    struct btrfs_free_space *info)
{}

/* Used by test_steal_space_from_bitmap_to_extent(). */
static int
check_num_extents_and_bitmaps(const struct btrfs_block_group *cache,
			      const int num_extents,
			      const int num_bitmaps)
{}

/* Used by test_steal_space_from_bitmap_to_extent(). */
static int check_cache_empty(struct btrfs_block_group *cache)
{}

/*
 * Before we were able to steal free space from a bitmap entry to an extent
 * entry, we could end up with 2 entries representing a contiguous free space.
 * One would be an extent entry and the other a bitmap entry. Since in order
 * to allocate space to a caller we use only 1 entry, we couldn't return that
 * whole range to the caller if it was requested. This forced the caller to
 * either assume ENOSPC or perform several smaller space allocations, which
 * wasn't optimal as they could be spread all over the block group while under
 * concurrency (extra overhead and fragmentation).
 *
 * This stealing approach is beneficial, since we always prefer to allocate
 * from extent entries, both for clustered and non-clustered allocation
 * requests.
 */
static int
test_steal_space_from_bitmap_to_extent(struct btrfs_block_group *cache,
				       u32 sectorsize)
{}

static bool bytes_index_use_bitmap(struct btrfs_free_space_ctl *ctl,
				   struct btrfs_free_space *info)
{}

static int test_bytes_index(struct btrfs_block_group *cache, u32 sectorsize)
{}

int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
{}