2323#include "extent-tree.h"
2424
2525#ifdef CONFIG_BTRFS_DEBUG
26- int btrfs_should_fragment_free_space (struct btrfs_block_group * block_group )
26+ int btrfs_should_fragment_free_space (const struct btrfs_block_group * block_group )
2727{
2828 struct btrfs_fs_info * fs_info = block_group -> fs_info ;
2929
@@ -40,9 +40,9 @@ int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group)
4040 *
4141 * Should be called with balance_lock held
4242 */
43- static u64 get_restripe_target (struct btrfs_fs_info * fs_info , u64 flags )
43+ static u64 get_restripe_target (const struct btrfs_fs_info * fs_info , u64 flags )
4444{
45- struct btrfs_balance_control * bctl = fs_info -> balance_ctl ;
45+ const struct btrfs_balance_control * bctl = fs_info -> balance_ctl ;
4646 u64 target = 0 ;
4747
4848 if (!bctl )
@@ -1415,9 +1415,9 @@ static int inc_block_group_ro(struct btrfs_block_group *cache, int force)
14151415}
14161416
14171417static bool clean_pinned_extents (struct btrfs_trans_handle * trans ,
1418- struct btrfs_block_group * bg )
1418+ const struct btrfs_block_group * bg )
14191419{
1420- struct btrfs_fs_info * fs_info = bg -> fs_info ;
1420+ struct btrfs_fs_info * fs_info = trans -> fs_info ;
14211421 struct btrfs_transaction * prev_trans = NULL ;
14221422 const u64 start = bg -> start ;
14231423 const u64 end = start + bg -> length - 1 ;
@@ -1756,14 +1756,14 @@ static int reclaim_bgs_cmp(void *unused, const struct list_head *a,
17561756 return bg1 -> used > bg2 -> used ;
17571757}
17581758
1759- static inline bool btrfs_should_reclaim (struct btrfs_fs_info * fs_info )
1759+ static inline bool btrfs_should_reclaim (const struct btrfs_fs_info * fs_info )
17601760{
17611761 if (btrfs_is_zoned (fs_info ))
17621762 return btrfs_zoned_should_reclaim (fs_info );
17631763 return true;
17641764}
17651765
1766- static bool should_reclaim_block_group (struct btrfs_block_group * bg , u64 bytes_freed )
1766+ static bool should_reclaim_block_group (const struct btrfs_block_group * bg , u64 bytes_freed )
17671767{
17681768 const int thresh_pct = btrfs_calc_reclaim_threshold (bg -> space_info );
17691769 u64 thresh_bytes = mult_perc (bg -> length , thresh_pct );
@@ -2006,8 +2006,8 @@ void btrfs_mark_bg_to_reclaim(struct btrfs_block_group *bg)
20062006 spin_unlock (& fs_info -> unused_bgs_lock );
20072007}
20082008
2009- static int read_bg_from_eb (struct btrfs_fs_info * fs_info , struct btrfs_key * key ,
2010- struct btrfs_path * path )
2009+ static int read_bg_from_eb (struct btrfs_fs_info * fs_info , const struct btrfs_key * key ,
2010+ const struct btrfs_path * path )
20112011{
20122012 struct btrfs_chunk_map * map ;
20132013 struct btrfs_block_group_item bg ;
@@ -2055,7 +2055,7 @@ static int read_bg_from_eb(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
20552055
20562056static int find_first_block_group (struct btrfs_fs_info * fs_info ,
20572057 struct btrfs_path * path ,
2058- struct btrfs_key * key )
2058+ const struct btrfs_key * key )
20592059{
20602060 struct btrfs_root * root = btrfs_block_group_root (fs_info );
20612061 int ret ;
@@ -2640,8 +2640,8 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans,
26402640}
26412641
26422642static int insert_dev_extent (struct btrfs_trans_handle * trans ,
2643- struct btrfs_device * device , u64 chunk_offset ,
2644- u64 start , u64 num_bytes )
2643+ const struct btrfs_device * device , u64 chunk_offset ,
2644+ u64 start , u64 num_bytes )
26452645{
26462646 struct btrfs_fs_info * fs_info = device -> fs_info ;
26472647 struct btrfs_root * root = fs_info -> dev_root ;
@@ -2817,7 +2817,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
28172817 * For extent tree v2 we use the block_group_item->chunk_offset to point at our
28182818 * global root id. For v1 it's always set to BTRFS_FIRST_CHUNK_TREE_OBJECTID.
28192819 */
2820- static u64 calculate_global_root_id (struct btrfs_fs_info * fs_info , u64 offset )
2820+ static u64 calculate_global_root_id (const struct btrfs_fs_info * fs_info , u64 offset )
28212821{
28222822 u64 div = SZ_1G ;
28232823 u64 index ;
@@ -3842,8 +3842,8 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
38423842 }
38433843}
38443844
3845- static int should_alloc_chunk (struct btrfs_fs_info * fs_info ,
3846- struct btrfs_space_info * sinfo , int force )
3845+ static int should_alloc_chunk (const struct btrfs_fs_info * fs_info ,
3846+ const struct btrfs_space_info * sinfo , int force )
38473847{
38483848 u64 bytes_used = btrfs_space_info_used (sinfo , false);
38493849 u64 thresh ;
@@ -4218,7 +4218,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
42184218 return ret ;
42194219}
42204220
4221- static u64 get_profile_num_devs (struct btrfs_fs_info * fs_info , u64 type )
4221+ static u64 get_profile_num_devs (const struct btrfs_fs_info * fs_info , u64 type )
42224222{
42234223 u64 num_dev ;
42244224
@@ -4622,7 +4622,7 @@ int btrfs_use_block_group_size_class(struct btrfs_block_group *bg,
46224622 return 0 ;
46234623}
46244624
4625- bool btrfs_block_group_should_use_size_class (struct btrfs_block_group * bg )
4625+ bool btrfs_block_group_should_use_size_class (const struct btrfs_block_group * bg )
46264626{
46274627 if (btrfs_is_zoned (bg -> fs_info ))
46284628 return false;
0 commit comments