From 07730d87ac7872b54efa02da5d20b42fd6bb165a Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Thu, 20 Jun 2019 15:38:04 -0400 Subject: btrfs: migrate the chunk allocation code This feels more at home in block-group.c than in extent-tree.c. Signed-off-by: Josef Bacik Reviewed-by: David Sterba i [ refresh ] Signed-off-by: David Sterba --- fs/btrfs/block-group.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'fs/btrfs/block-group.h') diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index 886bfa88ae06..de90f7311574 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -10,6 +10,23 @@ enum btrfs_disk_cache_state { BTRFS_DC_SETUP, }; +/* + * Control flags for do_chunk_alloc's force field CHUNK_ALLOC_NO_FORCE means to + * only allocate a chunk if we really need one. + * + * CHUNK_ALLOC_LIMITED means to only try and allocate one if we have very few + * chunks already allocated. This is used as part of the clustering code to + * help make sure we have a good pool of storage to cluster in, without filling + * the FS with empty chunks + * + * CHUNK_ALLOC_FORCE means it must try to allocate one + */ +enum btrfs_chunk_alloc_enum { + CHUNK_ALLOC_NO_FORCE, + CHUNK_ALLOC_LIMITED, + CHUNK_ALLOC_FORCE, +}; + struct btrfs_caching_control { struct list_head list; struct mutex mutex; @@ -198,6 +215,10 @@ int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, u64 ram_bytes, u64 num_bytes, int delalloc); void btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, u64 num_bytes, int delalloc); +int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags, + enum btrfs_chunk_alloc_enum force); +int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, u64 type); +void check_system_chunk(struct btrfs_trans_handle *trans, const u64 type); static inline int btrfs_block_group_cache_done( struct btrfs_block_group_cache *cache) -- cgit v1.2.3