mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
btrfs: relocation: constify parameters where possible
[ Upstream commit ab7c8bbf3a088730e58da224bcad512f1dd9ca74 ] Lots of the functions in relocation.c don't change pointer parameters but lack the annotations. Add them and reformat according to current coding style if needed. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com> Stable-dep-of: db7e68b522c0 ("btrfs: drop the backref cache during relocation if we commit") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
5ae94c6397
commit
4dc6ea8b4d
2 changed files with 33 additions and 32 deletions
|
@ -299,7 +299,7 @@ static int update_backref_cache(struct btrfs_trans_handle *trans,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool reloc_root_is_dead(struct btrfs_root *root)
|
static bool reloc_root_is_dead(const struct btrfs_root *root)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Pair with set_bit/clear_bit in clean_dirty_subvols and
|
* Pair with set_bit/clear_bit in clean_dirty_subvols and
|
||||||
|
@ -320,7 +320,7 @@ static bool reloc_root_is_dead(struct btrfs_root *root)
|
||||||
* from no reloc root. But btrfs_should_ignore_reloc_root() below is a
|
* from no reloc root. But btrfs_should_ignore_reloc_root() below is a
|
||||||
* special case.
|
* special case.
|
||||||
*/
|
*/
|
||||||
static bool have_reloc_root(struct btrfs_root *root)
|
static bool have_reloc_root(const struct btrfs_root *root)
|
||||||
{
|
{
|
||||||
if (reloc_root_is_dead(root))
|
if (reloc_root_is_dead(root))
|
||||||
return false;
|
return false;
|
||||||
|
@ -329,7 +329,7 @@ static bool have_reloc_root(struct btrfs_root *root)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool btrfs_should_ignore_reloc_root(struct btrfs_root *root)
|
bool btrfs_should_ignore_reloc_root(const struct btrfs_root *root)
|
||||||
{
|
{
|
||||||
struct btrfs_root *reloc_root;
|
struct btrfs_root *reloc_root;
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ out:
|
||||||
*/
|
*/
|
||||||
static int clone_backref_node(struct btrfs_trans_handle *trans,
|
static int clone_backref_node(struct btrfs_trans_handle *trans,
|
||||||
struct reloc_control *rc,
|
struct reloc_control *rc,
|
||||||
struct btrfs_root *src,
|
const struct btrfs_root *src,
|
||||||
struct btrfs_root *dest)
|
struct btrfs_root *dest)
|
||||||
{
|
{
|
||||||
struct btrfs_root *reloc_root = src->reloc_root;
|
struct btrfs_root *reloc_root = src->reloc_root;
|
||||||
|
@ -1186,9 +1186,9 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static noinline_for_stack
|
static noinline_for_stack int memcmp_node_keys(const struct extent_buffer *eb,
|
||||||
int memcmp_node_keys(struct extent_buffer *eb, int slot,
|
int slot, const struct btrfs_path *path,
|
||||||
struct btrfs_path *path, int level)
|
int level)
|
||||||
{
|
{
|
||||||
struct btrfs_disk_key key1;
|
struct btrfs_disk_key key1;
|
||||||
struct btrfs_disk_key key2;
|
struct btrfs_disk_key key2;
|
||||||
|
@ -1517,8 +1517,8 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
* [min_key, max_key)
|
* [min_key, max_key)
|
||||||
*/
|
*/
|
||||||
static int invalidate_extent_cache(struct btrfs_root *root,
|
static int invalidate_extent_cache(struct btrfs_root *root,
|
||||||
struct btrfs_key *min_key,
|
const struct btrfs_key *min_key,
|
||||||
struct btrfs_key *max_key)
|
const struct btrfs_key *max_key)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||||
struct inode *inode = NULL;
|
struct inode *inode = NULL;
|
||||||
|
@ -2829,7 +2829,7 @@ out_free_blocks:
|
||||||
|
|
||||||
static noinline_for_stack int prealloc_file_extent_cluster(
|
static noinline_for_stack int prealloc_file_extent_cluster(
|
||||||
struct btrfs_inode *inode,
|
struct btrfs_inode *inode,
|
||||||
struct file_extent_cluster *cluster)
|
const struct file_extent_cluster *cluster)
|
||||||
{
|
{
|
||||||
u64 alloc_hint = 0;
|
u64 alloc_hint = 0;
|
||||||
u64 start;
|
u64 start;
|
||||||
|
@ -2964,7 +2964,7 @@ static noinline_for_stack int setup_relocation_extent_mapping(struct inode *inod
|
||||||
/*
|
/*
|
||||||
* Allow error injection to test balance/relocation cancellation
|
* Allow error injection to test balance/relocation cancellation
|
||||||
*/
|
*/
|
||||||
noinline int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info)
|
noinline int btrfs_should_cancel_balance(const struct btrfs_fs_info *fs_info)
|
||||||
{
|
{
|
||||||
return atomic_read(&fs_info->balance_cancel_req) ||
|
return atomic_read(&fs_info->balance_cancel_req) ||
|
||||||
atomic_read(&fs_info->reloc_cancel_req) ||
|
atomic_read(&fs_info->reloc_cancel_req) ||
|
||||||
|
@ -2972,7 +2972,7 @@ noinline int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info)
|
||||||
}
|
}
|
||||||
ALLOW_ERROR_INJECTION(btrfs_should_cancel_balance, TRUE);
|
ALLOW_ERROR_INJECTION(btrfs_should_cancel_balance, TRUE);
|
||||||
|
|
||||||
static u64 get_cluster_boundary_end(struct file_extent_cluster *cluster,
|
static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster,
|
||||||
int cluster_nr)
|
int cluster_nr)
|
||||||
{
|
{
|
||||||
/* Last extent, use cluster end directly */
|
/* Last extent, use cluster end directly */
|
||||||
|
@ -2984,7 +2984,7 @@ static u64 get_cluster_boundary_end(struct file_extent_cluster *cluster,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
|
static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
|
||||||
struct file_extent_cluster *cluster,
|
const struct file_extent_cluster *cluster,
|
||||||
int *cluster_nr, unsigned long page_index)
|
int *cluster_nr, unsigned long page_index)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
|
@ -3119,7 +3119,7 @@ release_page:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int relocate_file_extent_cluster(struct inode *inode,
|
static int relocate_file_extent_cluster(struct inode *inode,
|
||||||
struct file_extent_cluster *cluster)
|
const struct file_extent_cluster *cluster)
|
||||||
{
|
{
|
||||||
u64 offset = BTRFS_I(inode)->index_cnt;
|
u64 offset = BTRFS_I(inode)->index_cnt;
|
||||||
unsigned long index;
|
unsigned long index;
|
||||||
|
@ -3157,8 +3157,8 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static noinline_for_stack
|
static noinline_for_stack int relocate_data_extent(struct inode *inode,
|
||||||
int relocate_data_extent(struct inode *inode, struct btrfs_key *extent_key,
|
const struct btrfs_key *extent_key,
|
||||||
struct file_extent_cluster *cluster)
|
struct file_extent_cluster *cluster)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -3192,7 +3192,7 @@ int relocate_data_extent(struct inode *inode, struct btrfs_key *extent_key,
|
||||||
* the major work is getting the generation and level of the block
|
* the major work is getting the generation and level of the block
|
||||||
*/
|
*/
|
||||||
static int add_tree_block(struct reloc_control *rc,
|
static int add_tree_block(struct reloc_control *rc,
|
||||||
struct btrfs_key *extent_key,
|
const struct btrfs_key *extent_key,
|
||||||
struct btrfs_path *path,
|
struct btrfs_path *path,
|
||||||
struct rb_root *blocks)
|
struct rb_root *blocks)
|
||||||
{
|
{
|
||||||
|
@ -3443,9 +3443,8 @@ static int delete_v1_space_cache(struct extent_buffer *leaf,
|
||||||
/*
|
/*
|
||||||
* helper to find all tree blocks that reference a given data extent
|
* helper to find all tree blocks that reference a given data extent
|
||||||
*/
|
*/
|
||||||
static noinline_for_stack
|
static noinline_for_stack int add_data_references(struct reloc_control *rc,
|
||||||
int add_data_references(struct reloc_control *rc,
|
const struct btrfs_key *extent_key,
|
||||||
struct btrfs_key *extent_key,
|
|
||||||
struct btrfs_path *path,
|
struct btrfs_path *path,
|
||||||
struct rb_root *blocks)
|
struct rb_root *blocks)
|
||||||
{
|
{
|
||||||
|
@ -3873,9 +3872,9 @@ out:
|
||||||
* helper to create inode for data relocation.
|
* helper to create inode for data relocation.
|
||||||
* the inode is in data relocation tree and its link count is 0
|
* the inode is in data relocation tree and its link count is 0
|
||||||
*/
|
*/
|
||||||
static noinline_for_stack
|
static noinline_for_stack struct inode *create_reloc_inode(
|
||||||
struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
|
struct btrfs_fs_info *fs_info,
|
||||||
struct btrfs_block_group *group)
|
const struct btrfs_block_group *group)
|
||||||
{
|
{
|
||||||
struct inode *inode = NULL;
|
struct inode *inode = NULL;
|
||||||
struct btrfs_trans_handle *trans;
|
struct btrfs_trans_handle *trans;
|
||||||
|
@ -4421,7 +4420,8 @@ int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered)
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
|
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root, struct extent_buffer *buf,
|
struct btrfs_root *root,
|
||||||
|
const struct extent_buffer *buf,
|
||||||
struct extent_buffer *cow)
|
struct extent_buffer *cow)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||||
|
@ -4560,7 +4560,7 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
|
||||||
*
|
*
|
||||||
* Return U64_MAX if no running relocation.
|
* Return U64_MAX if no running relocation.
|
||||||
*/
|
*/
|
||||||
u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info)
|
u64 btrfs_get_reloc_bg_bytenr(const struct btrfs_fs_info *fs_info)
|
||||||
{
|
{
|
||||||
u64 logical = U64_MAX;
|
u64 logical = U64_MAX;
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,16 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
|
||||||
int btrfs_recover_relocation(struct btrfs_fs_info *fs_info);
|
int btrfs_recover_relocation(struct btrfs_fs_info *fs_info);
|
||||||
int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered);
|
int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered);
|
||||||
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
|
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root, struct extent_buffer *buf,
|
struct btrfs_root *root,
|
||||||
|
const struct extent_buffer *buf,
|
||||||
struct extent_buffer *cow);
|
struct extent_buffer *cow);
|
||||||
void btrfs_reloc_pre_snapshot(struct btrfs_pending_snapshot *pending,
|
void btrfs_reloc_pre_snapshot(struct btrfs_pending_snapshot *pending,
|
||||||
u64 *bytes_to_reserve);
|
u64 *bytes_to_reserve);
|
||||||
int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
|
int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_pending_snapshot *pending);
|
struct btrfs_pending_snapshot *pending);
|
||||||
int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info);
|
int btrfs_should_cancel_balance(const struct btrfs_fs_info *fs_info);
|
||||||
struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
|
struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
|
||||||
bool btrfs_should_ignore_reloc_root(struct btrfs_root *root);
|
bool btrfs_should_ignore_reloc_root(const struct btrfs_root *root);
|
||||||
u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info);
|
u64 btrfs_get_reloc_bg_bytenr(const struct btrfs_fs_info *fs_info);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue