blob: 3133651d7d706acf0214cae98408604cb888c96a [file] [log] [blame]
David Sterba9888c342018-04-03 19:16:55 +02001/* SPDX-License-Identifier: GPL-2.0 */
Omar Sandovala5ed9182015-09-29 20:50:35 -07002/*
3 * Copyright (C) 2015 Facebook. All rights reserved.
Omar Sandovala5ed9182015-09-29 20:50:35 -07004 */
5
David Sterba9888c342018-04-03 19:16:55 +02006#ifndef BTRFS_FREE_SPACE_TREE_H
7#define BTRFS_FREE_SPACE_TREE_H
Omar Sandovala5ed9182015-09-29 20:50:35 -07008
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
17void set_free_space_tree_thresholds(struct btrfs_block_group_cache *block_group);
18int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info);
19int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info);
20int load_free_space_tree(struct btrfs_caching_control *caching_ctl);
21int add_block_group_free_space(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070022 struct btrfs_block_group_cache *block_group);
23int remove_block_group_free_space(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070024 struct btrfs_block_group_cache *block_group);
25int add_to_free_space_tree(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070026 u64 start, u64 size);
27int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070028 u64 start, u64 size);
29
Nikolay Borisov2d77ab32017-08-16 18:15:23 +030030#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
Omar Sandovala5ed9182015-09-29 20:50:35 -070031struct btrfs_free_space_info *
32search_free_space_info(struct btrfs_trans_handle *trans,
33 struct btrfs_fs_info *fs_info,
34 struct btrfs_block_group_cache *block_group,
35 struct btrfs_path *path, int cow);
36int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070037 struct btrfs_block_group_cache *block_group,
38 struct btrfs_path *path, u64 start, u64 size);
39int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070040 struct btrfs_block_group_cache *block_group,
41 struct btrfs_path *path, u64 start, u64 size);
42int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070043 struct btrfs_block_group_cache *block_group,
44 struct btrfs_path *path);
45int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
Omar Sandovala5ed9182015-09-29 20:50:35 -070046 struct btrfs_block_group_cache *block_group,
47 struct btrfs_path *path);
48int free_space_test_bit(struct btrfs_block_group_cache *block_group,
49 struct btrfs_path *path, u64 offset);
Nikolay Borisov2d77ab32017-08-16 18:15:23 +030050#endif
Omar Sandovala5ed9182015-09-29 20:50:35 -070051
52#endif