btrfs: small cleanups for relocation code
cover btrfs: small cleanups for relocation code
Here is a small series of cleanups I came across when debugging relocation related problems on RAID stripe tree.
None of them imposes a functional change.
---
Johannes Thumshirn (4):
btrfs: pass reloc_control to relocate_data_extent
btrfs: pass a reloc_control to relocate_file_extent_cluster
btrfs: pass a reloc_control to relocate_one_folio
btrfs: don't pass fs_info to describe_relocation
fs/btrfs/relocation.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
---
base-commit: d18729a15cd2ca4b71ac14727c33b7da87359b70
change-id: 20240605-reloc-cleanups-16ddf3d364b0
Best regards,
Signature · 1 line
Johannes Thumshirn <[email protected]>
PATCH 1/4 btrfs: pass reloc_control to relocate_data_extent
From: Johannes Thumshirn <[email protected]>
Pass a 'struct reloc_control' to relocate_data_extent() instead of it's data_inode and file_extent_cluster separately.
--- fs/btrfs/relocation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/relocation.c +5 -5
@@ -3123,10 +3123,11 @@ static int relocate_file_extent_cluster(struct inode *inode,return ret; } -static noinline_for_stack int relocate_data_extent(struct inode *inode, -const struct btrfs_key *extent_key, -struct file_extent_cluster *cluster) +static noinline_for_stack int relocate_data_extent(struct reloc_control *rc, +const struct btrfs_key *extent_key) { +struct inode *inode = rc->data_inode; +struct file_extent_cluster *cluster = &rc->cluster;int ret;struct btrfs_root *root =BTRFS_I (inode)->root;
@@ -3745,8 +3746,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)if (rc->stage ==MOVE_DATA_EXTENTS && (flags &BTRFS_EXTENT_FLAG_DATA )) { rc->found_file_extent = true; - ret =relocate_data_extent (rc->data_inode, - &key, &rc->cluster); + ret =relocate_data_extent (rc, &key);if (ret <0 ) { err = ret;break ;
Signature · 1 line
2.43.0
PATCH 2/4 btrfs: pass a reloc_control to relocate_file_extent_cluster
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
Instead of passing in a reloc_control's data_inode and file_extent_cluster members, pass in the whole reloc_control structure.
--- fs/btrfs/relocation.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/relocation.c +7 -7
@@ -3084,9 +3084,10 @@ static int relocate_one_folio(struct inode *inode, struct file_ra_state *ra,return ret; } -static int relocate_file_extent_cluster (struct inode *inode, -const struct file_extent_cluster *cluster) +static int relocate_file_extent_cluster (struct reloc_control *rc) { +struct inode *inode = rc->data_inode; +const struct file_extent_cluster *cluster = &rc->cluster;u64 offset =BTRFS_I (inode)->reloc_block_group_start;unsigned long index;unsigned long last_index;
@@ -3132,7 +3133,7 @@ static noinline_for_stack int relocate_data_extent(struct reloc_control *rc,struct btrfs_root *root =BTRFS_I (inode)->root;if (cluster->nr >0 && extent_key->objectid != cluster->end +1 ) { - ret =relocate_file_extent_cluster (inode, cluster); + ret =relocate_file_extent_cluster (rc);if (ret)return ret; cluster->nr =0 ;
@@ -3158,7 +3159,7 @@ static noinline_for_stack int relocate_data_extent(struct reloc_control *rc,* the cluster we need to relocate. */ root->relocation_src_root = cluster->owning_root; - ret =relocate_file_extent_cluster (inode, cluster); + ret =relocate_file_extent_cluster (rc);if (ret)return ret; cluster->nr =0 ;
@@ -3177,7 +3178,7 @@ static noinline_for_stack int relocate_data_extent(struct reloc_control *rc, cluster->nr++;if (cluster->nr >=MAX_EXTENTS ) { - ret =relocate_file_extent_cluster (inode, cluster); + ret =relocate_file_extent_cluster (rc);if (ret)return ret; cluster->nr =0 ;
@@ -3775,8 +3776,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) }if (!err) { - ret =relocate_file_extent_cluster (rc->data_inode, - &rc->cluster); + ret =relocate_file_extent_cluster (rc);if (ret <0 ) err = ret; }
Signature · 1 line
2.43.0
PATCH 3/4 btrfs: pass a reloc_control to relocate_one_folio
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
Pass a struct reloc_control to relocate_one_folio, instead of passing it's members data_inode and cluster as separate arguments to the function.
--- fs/btrfs/relocation.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/btrfs/relocation.c +5 -3
@@ -2947,10 +2947,12 @@ static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster,return cluster->boundary[cluster_nr +1 ] -1 ; } -static int relocate_one_folio (struct inode *inode,struct file_ra_state *ra, -const struct file_extent_cluster *cluster, +static int relocate_one_folio (struct reloc_control *rc, +struct file_ra_state *ra,int *cluster_nr,unsigned long index) { +const struct file_extent_cluster *cluster = &rc->cluster; +struct inode *inode = rc->data_inode;struct btrfs_fs_info *fs_info =inode_to_fs_info (inode);u64 offset =BTRFS_I (inode)->reloc_block_group_start;const unsigned long last_index = (cluster->end - offset) >>PAGE_SHIFT ;
@@ -3116,7 +3118,7 @@ static int relocate_file_extent_cluster(struct reloc_control *rc) last_index = (cluster->end - offset) >>PAGE_SHIFT ;for (index = (cluster->start - offset) >>PAGE_SHIFT ; index <= last_index && !ret; index++) - ret =relocate_one_folio (inode, ra, cluster, &cluster_nr, index); + ret =relocate_one_folio (rc, ra, &cluster_nr, index);if (ret ==0 )WARN_ON (cluster_nr != cluster->nr); out:
Signature · 1 line
2.43.0
PATCH 4/4 btrfs: don't pass fs_info to describe_relocation
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
In describe_relocation() the fs_info is only needed for printing information via btrfs_info() and can easily be accessed via the passed in 'struct btrfs_block_group'.
So we can savely remove the fs_info parameter.
--- fs/btrfs/relocation.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/relocation.c +3 -5
@@ -4005,15 +4005,13 @@ static void free_reloc_control(struct reloc_control *rc)/* * Print the block group being relocated */ -static void describe_relocation (struct btrfs_fs_info *fs_info, -struct btrfs_block_group *block_group) +static void describe_relocation (struct btrfs_block_group *block_group) {char buf[128 ] = {'\0' };btrfs_describe_block_groups (block_group->flags, buf,sizeof (buf)); -btrfs_info (fs_info, -"relocating block group %llu flags %s" , +btrfs_info (block_group->fs_info,"relocating block group %llu flags %s" , block_group->start, buf); }
@@ -4121,7 +4119,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) goto out; } -describe_relocation (fs_info, rc->block_group); +describe_relocation (rc->block_group);btrfs_wait_block_group_reservations (rc->block_group);btrfs_wait_nocow_writers (rc->block_group);
Signature · 1 line
2.43.0
Quoted 13 lines · Johannes Thumshirn
Here is a small series of cleanups I came across when debugging relocation related problems on RAID stripe tree.
None of them imposes a functional change.
Signed-off-by Johannes Thumshirn <[email protected]>---
Johannes Thumshirn (4):
btrfs: passreloc_controltorelocate_data_extent
btrfs: pass areloc_controltorelocate_file_extent_cluster
btrfs: pass areloc_controltorelocate_one_folio
btrfs: don't passfs_infotodescribe_relocation
Quoted 3 lines
fs/btrfs/relocation.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)---
Thanks,
Josef
Quoted 5 lines · Johannes Thumshirn
Here is a small series of cleanups I came across when debugging relocation related problems on RAID stripe tree.
None of them imposes a functional change.
Quoted 7 lines
Signed-off-by Johannes Thumshirn <[email protected]>---
Johannes Thumshirn (4):
btrfs: passreloc_controltorelocate_data_extent
btrfs: pass areloc_controltorelocate_file_extent_cluster
btrfs: pass areloc_controltorelocate_one_folio
btrfs: don't passfs_infotodescribe_relocation