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