#include <linux/kernel.h>
#include <linux/sched/mm.h>
#include "free-space-tree.h"
static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path);
void set_free_space_tree_thresholds(struct btrfs_block_group_cache *cache)
u64 num_bitmaps, total_bitmap_size;
bitmap_range = cache->fs_info->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS;
num_bitmaps = div_u64(cache->key.offset + bitmap_range - 1,
bitmap_size = sizeof(struct btrfs_item) + BTRFS_FREE_SPACE_BITMAP_SIZE;
total_bitmap_size = num_bitmaps * bitmap_size;
cache->bitmap_high_thresh = div_u64(total_bitmap_size,
sizeof(struct btrfs_item));
if (cache->bitmap_high_thresh > 100)
cache->bitmap_low_thresh = cache->bitmap_high_thresh - 100;
cache->bitmap_low_thresh = 0;
static int add_new_free_space_info(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_root *root = trans->fs_info->free_space_root;
struct btrfs_free_space_info *info;
struct extent_buffer *leaf;
key.objectid = block_group->key.objectid;
key.type = BTRFS_FREE_SPACE_INFO_KEY;
key.offset = block_group->key.offset;
ret = btrfs_insert_empty_item(trans, root, path, &key, sizeof(*info));