Commit ca283ea9 authored by David Sterba's avatar David Sterba
Browse files

btrfs: constify more pointer parameters



Continue adding const to parameters.  This is for clarity and minor
addition to safety. There are some minor effects, in the assembly code
and .ko measured on release config.

Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 070969f1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -219,8 +219,8 @@ static void free_pref(struct prelim_ref *ref)
 * A -1 return indicates ref1 is a 'lower' block than ref2, while 1
 * indicates a 'higher' block.
 */
static int prelim_ref_compare(struct prelim_ref *ref1,
			      struct prelim_ref *ref2)
static int prelim_ref_compare(const struct prelim_ref *ref1,
			      const struct prelim_ref *ref2)
{
	if (ref1->level < ref2->level)
		return -1;
@@ -251,7 +251,7 @@ static int prelim_ref_compare(struct prelim_ref *ref1,
}

static void update_share_count(struct share_check *sc, int oldcount,
			       int newcount, struct prelim_ref *newref)
			       int newcount, const struct prelim_ref *newref)
{
	if ((!sc) || (oldcount == 0 && newcount < 1))
		return;
+17 −17
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include "extent-tree.h"

#ifdef CONFIG_BTRFS_DEBUG
int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group)
int btrfs_should_fragment_free_space(const struct btrfs_block_group *block_group)
{
	struct btrfs_fs_info *fs_info = block_group->fs_info;

@@ -40,9 +40,9 @@ int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group)
 *
 * Should be called with balance_lock held
 */
static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)
static u64 get_restripe_target(const struct btrfs_fs_info *fs_info, u64 flags)
{
	struct btrfs_balance_control *bctl = fs_info->balance_ctl;
	const struct btrfs_balance_control *bctl = fs_info->balance_ctl;
	u64 target = 0;

	if (!bctl)
@@ -1415,9 +1415,9 @@ static int inc_block_group_ro(struct btrfs_block_group *cache, int force)
}

static bool clean_pinned_extents(struct btrfs_trans_handle *trans,
				 struct btrfs_block_group *bg)
				 const struct btrfs_block_group *bg)
{
	struct btrfs_fs_info *fs_info = bg->fs_info;
	struct btrfs_fs_info *fs_info = trans->fs_info;
	struct btrfs_transaction *prev_trans = NULL;
	const u64 start = bg->start;
	const u64 end = start + bg->length - 1;
@@ -1756,14 +1756,14 @@ static int reclaim_bgs_cmp(void *unused, const struct list_head *a,
	return bg1->used > bg2->used;
}

static inline bool btrfs_should_reclaim(struct btrfs_fs_info *fs_info)
static inline bool btrfs_should_reclaim(const struct btrfs_fs_info *fs_info)
{
	if (btrfs_is_zoned(fs_info))
		return btrfs_zoned_should_reclaim(fs_info);
	return true;
}

static bool should_reclaim_block_group(struct btrfs_block_group *bg, u64 bytes_freed)
static bool should_reclaim_block_group(const struct btrfs_block_group *bg, u64 bytes_freed)
{
	const int thresh_pct = btrfs_calc_reclaim_threshold(bg->space_info);
	u64 thresh_bytes = mult_perc(bg->length, thresh_pct);
@@ -2006,8 +2006,8 @@ void btrfs_mark_bg_to_reclaim(struct btrfs_block_group *bg)
	spin_unlock(&fs_info->unused_bgs_lock);
}

static int read_bg_from_eb(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
			   struct btrfs_path *path)
static int read_bg_from_eb(struct btrfs_fs_info *fs_info, const struct btrfs_key *key,
			   const struct btrfs_path *path)
{
	struct btrfs_chunk_map *map;
	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,

static int find_first_block_group(struct btrfs_fs_info *fs_info,
				  struct btrfs_path *path,
				  struct btrfs_key *key)
				  const struct btrfs_key *key)
{
	struct btrfs_root *root = btrfs_block_group_root(fs_info);
	int ret;
@@ -2640,7 +2640,7 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans,
}

static int insert_dev_extent(struct btrfs_trans_handle *trans,
			    struct btrfs_device *device, u64 chunk_offset,
			     const struct btrfs_device *device, u64 chunk_offset,
			     u64 start, u64 num_bytes)
{
	struct btrfs_fs_info *fs_info = device->fs_info;
@@ -2817,7 +2817,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
 * For extent tree v2 we use the block_group_item->chunk_offset to point at our
 * global root id.  For v1 it's always set to BTRFS_FIRST_CHUNK_TREE_OBJECTID.
 */
static u64 calculate_global_root_id(struct btrfs_fs_info *fs_info, u64 offset)
static u64 calculate_global_root_id(const struct btrfs_fs_info *fs_info, u64 offset)
{
	u64 div = SZ_1G;
	u64 index;
@@ -3842,8 +3842,8 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
	}
}

static int should_alloc_chunk(struct btrfs_fs_info *fs_info,
			      struct btrfs_space_info *sinfo, int force)
static int should_alloc_chunk(const struct btrfs_fs_info *fs_info,
			      const struct btrfs_space_info *sinfo, int force)
{
	u64 bytes_used = btrfs_space_info_used(sinfo, false);
	u64 thresh;
@@ -4218,7 +4218,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
	return ret;
}

static u64 get_profile_num_devs(struct btrfs_fs_info *fs_info, u64 type)
static u64 get_profile_num_devs(const struct btrfs_fs_info *fs_info, u64 type)
{
	u64 num_dev;

@@ -4622,7 +4622,7 @@ int btrfs_use_block_group_size_class(struct btrfs_block_group *bg,
	return 0;
}

bool btrfs_block_group_should_use_size_class(struct btrfs_block_group *bg)
bool btrfs_block_group_should_use_size_class(const struct btrfs_block_group *bg)
{
	if (btrfs_is_zoned(bg->fs_info))
		return false;
+5 −6
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ struct btrfs_block_group {
	u64 reclaim_mark;
};

static inline u64 btrfs_block_group_end(struct btrfs_block_group *block_group)
static inline u64 btrfs_block_group_end(const struct btrfs_block_group *block_group)
{
	return (block_group->start + block_group->length);
}
@@ -278,8 +278,7 @@ static inline bool btrfs_is_block_group_used(const struct btrfs_block_group *bg)
	return (bg->used > 0 || bg->reserved > 0 || bg->pinned > 0);
}

static inline bool btrfs_is_block_group_data_only(
					struct btrfs_block_group *block_group)
static inline bool btrfs_is_block_group_data_only(const struct btrfs_block_group *block_group)
{
	/*
	 * In mixed mode the fragmentation is expected to be high, lowering the
@@ -290,7 +289,7 @@ static inline bool btrfs_is_block_group_data_only(
}

#ifdef CONFIG_BTRFS_DEBUG
int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group);
int btrfs_should_fragment_free_space(const struct btrfs_block_group *block_group);
#endif

struct btrfs_block_group *btrfs_lookup_first_block_group(
@@ -370,7 +369,7 @@ static inline u64 btrfs_system_alloc_profile(struct btrfs_fs_info *fs_info)
	return btrfs_get_alloc_profile(fs_info, BTRFS_BLOCK_GROUP_SYSTEM);
}

static inline int btrfs_block_group_done(struct btrfs_block_group *cache)
static inline int btrfs_block_group_done(const struct btrfs_block_group *cache)
{
	smp_mb();
	return cache->cached == BTRFS_CACHE_FINISHED ||
@@ -387,6 +386,6 @@ enum btrfs_block_group_size_class btrfs_calc_block_group_size_class(u64 size);
int btrfs_use_block_group_size_class(struct btrfs_block_group *bg,
				     enum btrfs_block_group_size_class size_class,
				     bool force_wrong_size_class);
bool btrfs_block_group_should_use_size_class(struct btrfs_block_group *bg);
bool btrfs_block_group_should_use_size_class(const struct btrfs_block_group *bg);

#endif /* BTRFS_BLOCK_GROUP_H */
+1 −1
Original line number Diff line number Diff line
@@ -553,7 +553,7 @@ struct btrfs_block_rsv *btrfs_use_block_rsv(struct btrfs_trans_handle *trans,
	return ERR_PTR(ret);
}

int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
int btrfs_check_trunc_cache_free_space(const struct btrfs_fs_info *fs_info,
				       struct btrfs_block_rsv *rsv)
{
	u64 needed_bytes;
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ void btrfs_release_global_block_rsv(struct btrfs_fs_info *fs_info);
struct btrfs_block_rsv *btrfs_use_block_rsv(struct btrfs_trans_handle *trans,
					    struct btrfs_root *root,
					    u32 blocksize);
int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
int btrfs_check_trunc_cache_free_space(const struct btrfs_fs_info *fs_info,
				       struct btrfs_block_rsv *rsv);
static inline void btrfs_unuse_block_rsv(struct btrfs_fs_info *fs_info,
					 struct btrfs_block_rsv *block_rsv,
Loading