Skip to content

Commit 4dc6ea8

Browse files
kdavegregkh
authored andcommitted
btrfs: relocation: constify parameters where possible
[ Upstream commit ab7c8bb ] 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 <[email protected]> Signed-off-by: David Sterba <[email protected]> Stable-dep-of: db7e68b ("btrfs: drop the backref cache during relocation if we commit") Signed-off-by: Sasha Levin <[email protected]>
1 parent 5ae94c6 commit 4dc6ea8

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

fs/btrfs/relocation.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int update_backref_cache(struct btrfs_trans_handle *trans,
299299
return 1;
300300
}
301301

302-
static bool reloc_root_is_dead(struct btrfs_root *root)
302+
static bool reloc_root_is_dead(const struct btrfs_root *root)
303303
{
304304
/*
305305
* 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)
320320
* from no reloc root. But btrfs_should_ignore_reloc_root() below is a
321321
* special case.
322322
*/
323-
static bool have_reloc_root(struct btrfs_root *root)
323+
static bool have_reloc_root(const struct btrfs_root *root)
324324
{
325325
if (reloc_root_is_dead(root))
326326
return false;
@@ -329,7 +329,7 @@ static bool have_reloc_root(struct btrfs_root *root)
329329
return true;
330330
}
331331

332-
bool btrfs_should_ignore_reloc_root(struct btrfs_root *root)
332+
bool btrfs_should_ignore_reloc_root(const struct btrfs_root *root)
333333
{
334334
struct btrfs_root *reloc_root;
335335

@@ -546,7 +546,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
546546
*/
547547
static int clone_backref_node(struct btrfs_trans_handle *trans,
548548
struct reloc_control *rc,
549-
struct btrfs_root *src,
549+
const struct btrfs_root *src,
550550
struct btrfs_root *dest)
551551
{
552552
struct btrfs_root *reloc_root = src->reloc_root;
@@ -1186,9 +1186,9 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
11861186
return ret;
11871187
}
11881188

1189-
static noinline_for_stack
1190-
int memcmp_node_keys(struct extent_buffer *eb, int slot,
1191-
struct btrfs_path *path, int level)
1189+
static noinline_for_stack int memcmp_node_keys(const struct extent_buffer *eb,
1190+
int slot, const struct btrfs_path *path,
1191+
int level)
11921192
{
11931193
struct btrfs_disk_key key1;
11941194
struct btrfs_disk_key key2;
@@ -1517,8 +1517,8 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
15171517
* [min_key, max_key)
15181518
*/
15191519
static int invalidate_extent_cache(struct btrfs_root *root,
1520-
struct btrfs_key *min_key,
1521-
struct btrfs_key *max_key)
1520+
const struct btrfs_key *min_key,
1521+
const struct btrfs_key *max_key)
15221522
{
15231523
struct btrfs_fs_info *fs_info = root->fs_info;
15241524
struct inode *inode = NULL;
@@ -2829,7 +2829,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
28292829

28302830
static noinline_for_stack int prealloc_file_extent_cluster(
28312831
struct btrfs_inode *inode,
2832-
struct file_extent_cluster *cluster)
2832+
const struct file_extent_cluster *cluster)
28332833
{
28342834
u64 alloc_hint = 0;
28352835
u64 start;
@@ -2964,15 +2964,15 @@ static noinline_for_stack int setup_relocation_extent_mapping(struct inode *inod
29642964
/*
29652965
* Allow error injection to test balance/relocation cancellation
29662966
*/
2967-
noinline int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info)
2967+
noinline int btrfs_should_cancel_balance(const struct btrfs_fs_info *fs_info)
29682968
{
29692969
return atomic_read(&fs_info->balance_cancel_req) ||
29702970
atomic_read(&fs_info->reloc_cancel_req) ||
29712971
fatal_signal_pending(current);
29722972
}
29732973
ALLOW_ERROR_INJECTION(btrfs_should_cancel_balance, TRUE);
29742974

2975-
static u64 get_cluster_boundary_end(struct file_extent_cluster *cluster,
2975+
static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster,
29762976
int cluster_nr)
29772977
{
29782978
/* Last extent, use cluster end directly */
@@ -2984,7 +2984,7 @@ static u64 get_cluster_boundary_end(struct file_extent_cluster *cluster,
29842984
}
29852985

29862986
static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
2987-
struct file_extent_cluster *cluster,
2987+
const struct file_extent_cluster *cluster,
29882988
int *cluster_nr, unsigned long page_index)
29892989
{
29902990
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -3119,7 +3119,7 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
31193119
}
31203120

31213121
static int relocate_file_extent_cluster(struct inode *inode,
3122-
struct file_extent_cluster *cluster)
3122+
const struct file_extent_cluster *cluster)
31233123
{
31243124
u64 offset = BTRFS_I(inode)->index_cnt;
31253125
unsigned long index;
@@ -3157,9 +3157,9 @@ static int relocate_file_extent_cluster(struct inode *inode,
31573157
return ret;
31583158
}
31593159

3160-
static noinline_for_stack
3161-
int relocate_data_extent(struct inode *inode, struct btrfs_key *extent_key,
3162-
struct file_extent_cluster *cluster)
3160+
static noinline_for_stack int relocate_data_extent(struct inode *inode,
3161+
const struct btrfs_key *extent_key,
3162+
struct file_extent_cluster *cluster)
31633163
{
31643164
int ret;
31653165

@@ -3192,7 +3192,7 @@ int relocate_data_extent(struct inode *inode, struct btrfs_key *extent_key,
31923192
* the major work is getting the generation and level of the block
31933193
*/
31943194
static int add_tree_block(struct reloc_control *rc,
3195-
struct btrfs_key *extent_key,
3195+
const struct btrfs_key *extent_key,
31963196
struct btrfs_path *path,
31973197
struct rb_root *blocks)
31983198
{
@@ -3443,11 +3443,10 @@ static int delete_v1_space_cache(struct extent_buffer *leaf,
34433443
/*
34443444
* helper to find all tree blocks that reference a given data extent
34453445
*/
3446-
static noinline_for_stack
3447-
int add_data_references(struct reloc_control *rc,
3448-
struct btrfs_key *extent_key,
3449-
struct btrfs_path *path,
3450-
struct rb_root *blocks)
3446+
static noinline_for_stack int add_data_references(struct reloc_control *rc,
3447+
const struct btrfs_key *extent_key,
3448+
struct btrfs_path *path,
3449+
struct rb_root *blocks)
34513450
{
34523451
struct btrfs_backref_walk_ctx ctx = { 0 };
34533452
struct ulist_iterator leaf_uiter;
@@ -3873,9 +3872,9 @@ static void delete_orphan_inode(struct btrfs_trans_handle *trans,
38733872
* helper to create inode for data relocation.
38743873
* the inode is in data relocation tree and its link count is 0
38753874
*/
3876-
static noinline_for_stack
3877-
struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
3878-
struct btrfs_block_group *group)
3875+
static noinline_for_stack struct inode *create_reloc_inode(
3876+
struct btrfs_fs_info *fs_info,
3877+
const struct btrfs_block_group *group)
38793878
{
38803879
struct inode *inode = NULL;
38813880
struct btrfs_trans_handle *trans;
@@ -4421,7 +4420,8 @@ int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered)
44214420
}
44224421

44234422
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
4424-
struct btrfs_root *root, struct extent_buffer *buf,
4423+
struct btrfs_root *root,
4424+
const struct extent_buffer *buf,
44254425
struct extent_buffer *cow)
44264426
{
44274427
struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4560,7 +4560,7 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
45604560
*
45614561
* Return U64_MAX if no running relocation.
45624562
*/
4563-
u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info)
4563+
u64 btrfs_get_reloc_bg_bytenr(const struct btrfs_fs_info *fs_info)
45644564
{
45654565
u64 logical = U64_MAX;
45664566

fs/btrfs/relocation.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
1010
int btrfs_recover_relocation(struct btrfs_fs_info *fs_info);
1111
int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered);
1212
int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
13-
struct btrfs_root *root, struct extent_buffer *buf,
13+
struct btrfs_root *root,
14+
const struct extent_buffer *buf,
1415
struct extent_buffer *cow);
1516
void btrfs_reloc_pre_snapshot(struct btrfs_pending_snapshot *pending,
1617
u64 *bytes_to_reserve);
1718
int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
1819
struct btrfs_pending_snapshot *pending);
19-
int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info);
20+
int btrfs_should_cancel_balance(const struct btrfs_fs_info *fs_info);
2021
struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
21-
bool btrfs_should_ignore_reloc_root(struct btrfs_root *root);
22-
u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info);
22+
bool btrfs_should_ignore_reloc_root(const struct btrfs_root *root);
23+
u64 btrfs_get_reloc_bg_bytenr(const struct btrfs_fs_info *fs_info);
2324

2425
#endif

0 commit comments

Comments
 (0)