From 8c028efe4a31e15c0d106daf6218dedc373273c6 Mon Sep 17 00:00:00 2001 From: Nikolay Borisov Date: Mon, 1 Oct 2018 17:46:16 +0300 Subject: btrfs-progs: Pull free space tree related code from kernel To help implement free space tree checker in user space some kernel function are necessary, namely iterating/deleting/adding freespace items, some internal search functions. Functions to populate a block group based on the extent tree. The code is largely copy/paste from the kernel with locking eliminated (i.e free_space_lock). It supports reading/writing of both bitmap and extent based FST trees. Signed-off-by: Nikolay Borisov Signed-off-by: David Sterba --- ctree.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ctree.h') diff --git a/ctree.h b/ctree.h index 49f0f518..a6d6c3de 100644 --- a/ctree.h +++ b/ctree.h @@ -1071,6 +1071,17 @@ struct btrfs_block_group_cache { u64 flags; int cached; int ro; + /* + * If the free space extent count exceeds this number, convert the block + * group to bitmaps. + */ + u32 bitmap_high_thresh; + /* + * If the free space extent count drops below this number, convert the + * block group back to extents. + */ + u32 bitmap_low_thresh; + }; struct btrfs_device; @@ -2596,6 +2607,10 @@ int btrfs_split_item(struct btrfs_trans_handle *trans, int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key, struct btrfs_path *p, int ins_len, int cow); +int btrfs_search_slot_for_read(struct btrfs_root *root, + const struct btrfs_key *key, + struct btrfs_path *p, int find_higher, + int return_any); int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path, u64 iobjectid, u64 ioff, u8 key_type, struct btrfs_key *found_key); -- cgit v1.2.3