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