public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] btrfs: small cleanups for relocation code
@ 2024-06-05 13:17 Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 1/4] btrfs: pass reloc_control to relocate_data_extent Johannes Thumshirn
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2024-06-05 13:17 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, 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 <johannes.thumshirn@wdc.com>
---
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,
-- 
Johannes Thumshirn <jth@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] btrfs: pass reloc_control to relocate_data_extent
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
@ 2024-06-05 13:17 ` Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 2/4] btrfs: pass a reloc_control to relocate_file_extent_cluster Johannes Thumshirn
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2024-06-05 13:17 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Pass a 'struct reloc_control' to relocate_data_extent() instead of
it's data_inode and file_extent_cluster separately.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/relocation.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 81836a38325a..442d3c074477 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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;

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] btrfs: pass a reloc_control to relocate_file_extent_cluster
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 1/4] btrfs: pass reloc_control to relocate_data_extent Johannes Thumshirn
@ 2024-06-05 13:17 ` Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 3/4] btrfs: pass a reloc_control to relocate_one_folio Johannes Thumshirn
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2024-06-05 13:17 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Instead of passing in a reloc_control's data_inode and
file_extent_cluster members, pass in the whole reloc_control structure.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/relocation.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 442d3c074477..e23220bb2d53 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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;
 	}

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] btrfs: pass a reloc_control to relocate_one_folio
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 1/4] btrfs: pass reloc_control to relocate_data_extent Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 2/4] btrfs: pass a reloc_control to relocate_file_extent_cluster Johannes Thumshirn
@ 2024-06-05 13:17 ` Johannes Thumshirn
  2024-06-05 13:17 ` [PATCH 4/4] btrfs: don't pass fs_info to describe_relocation Johannes Thumshirn
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2024-06-05 13:17 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/relocation.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index e23220bb2d53..a43118a70916 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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:

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] btrfs: don't pass fs_info to describe_relocation
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
                   ` (2 preceding siblings ...)
  2024-06-05 13:17 ` [PATCH 3/4] btrfs: pass a reloc_control to relocate_one_folio Johannes Thumshirn
@ 2024-06-05 13:17 ` Johannes Thumshirn
  2024-06-05 15:37 ` [PATCH 0/4] btrfs: small cleanups for relocation code Josef Bacik
  2024-06-05 18:04 ` David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2024-06-05 13:17 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/relocation.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index a43118a70916..df3f7c11cfce 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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);

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] btrfs: small cleanups for relocation code
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
                   ` (3 preceding siblings ...)
  2024-06-05 13:17 ` [PATCH 4/4] btrfs: don't pass fs_info to describe_relocation Johannes Thumshirn
@ 2024-06-05 15:37 ` Josef Bacik
  2024-06-05 18:04 ` David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: Josef Bacik @ 2024-06-05 15:37 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	Johannes Thumshirn

On Wed, Jun 05, 2024 at 03:17:48PM +0200, Johannes Thumshirn wrote:
> 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 <johannes.thumshirn@wdc.com>
> ---
> 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(-)
> ---

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] btrfs: small cleanups for relocation code
  2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
                   ` (4 preceding siblings ...)
  2024-06-05 15:37 ` [PATCH 0/4] btrfs: small cleanups for relocation code Josef Bacik
@ 2024-06-05 18:04 ` David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2024-06-05 18:04 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel,
	Johannes Thumshirn

On Wed, Jun 05, 2024 at 03:17:48PM +0200, Johannes Thumshirn wrote:
> 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 <johannes.thumshirn@wdc.com>
> ---
> 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

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-05 18:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 13:17 [PATCH 0/4] btrfs: small cleanups for relocation code Johannes Thumshirn
2024-06-05 13:17 ` [PATCH 1/4] btrfs: pass reloc_control to relocate_data_extent Johannes Thumshirn
2024-06-05 13:17 ` [PATCH 2/4] btrfs: pass a reloc_control to relocate_file_extent_cluster Johannes Thumshirn
2024-06-05 13:17 ` [PATCH 3/4] btrfs: pass a reloc_control to relocate_one_folio Johannes Thumshirn
2024-06-05 13:17 ` [PATCH 4/4] btrfs: don't pass fs_info to describe_relocation Johannes Thumshirn
2024-06-05 15:37 ` [PATCH 0/4] btrfs: small cleanups for relocation code Josef Bacik
2024-06-05 18:04 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox