1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2015 Facebook. All rights reserved. 4 */ 5 6 #ifndef BTRFS_FREE_SPACE_TREE_H 7 #define BTRFS_FREE_SPACE_TREE_H 8 9 /* 10 * The default size for new free space bitmap items. The last bitmap in a block 11 * group may be truncated, and none of the free space tree code assumes that 12 * existing bitmaps are this size. 13 */ 14 #define BTRFS_FREE_SPACE_BITMAP_SIZE 256 15 #define BTRFS_FREE_SPACE_BITMAP_BITS (BTRFS_FREE_SPACE_BITMAP_SIZE * BITS_PER_BYTE) 16 17 void set_free_space_tree_thresholds(struct btrfs_block_group_cache *block_group); 18 int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info); 19 int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info); 20 int load_free_space_tree(struct btrfs_caching_control *caching_ctl); 21 int add_block_group_free_space(struct btrfs_trans_handle *trans, 22 struct btrfs_fs_info *fs_info, 23 struct btrfs_block_group_cache *block_group); 24 int remove_block_group_free_space(struct btrfs_trans_handle *trans, 25 struct btrfs_fs_info *fs_info, 26 struct btrfs_block_group_cache *block_group); 27 int add_to_free_space_tree(struct btrfs_trans_handle *trans, 28 struct btrfs_fs_info *fs_info, 29 u64 start, u64 size); 30 int remove_from_free_space_tree(struct btrfs_trans_handle *trans, 31 struct btrfs_fs_info *fs_info, 32 u64 start, u64 size); 33 34 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 35 struct btrfs_free_space_info * 36 search_free_space_info(struct btrfs_trans_handle *trans, 37 struct btrfs_fs_info *fs_info, 38 struct btrfs_block_group_cache *block_group, 39 struct btrfs_path *path, int cow); 40 int __add_to_free_space_tree(struct btrfs_trans_handle *trans, 41 struct btrfs_fs_info *fs_info, 42 struct btrfs_block_group_cache *block_group, 43 struct btrfs_path *path, u64 start, u64 size); 44 int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, 45 struct btrfs_fs_info *fs_info, 46 struct btrfs_block_group_cache *block_group, 47 struct btrfs_path *path, u64 start, u64 size); 48 int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, 49 struct btrfs_fs_info *fs_info, 50 struct btrfs_block_group_cache *block_group, 51 struct btrfs_path *path); 52 int convert_free_space_to_extents(struct btrfs_trans_handle *trans, 53 struct btrfs_fs_info *fs_info, 54 struct btrfs_block_group_cache *block_group, 55 struct btrfs_path *path); 56 int free_space_test_bit(struct btrfs_block_group_cache *block_group, 57 struct btrfs_path *path, u64 offset); 58 #endif 59 60 #endif 61