linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: drop unused argument of calcu_metadata_size()
@ 2024-04-24  6:38 Naohiro Aota
  2024-04-24  6:53 ` Qu Wenruo
  2024-04-24  7:57 ` Johannes Thumshirn
  0 siblings, 2 replies; 3+ messages in thread
From: Naohiro Aota @ 2024-04-24  6:38 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Naohiro Aota

calcu_metadata_size() has a "reserve" argument, but the only caller always
set it to "1". The other usage (reserve = 0) is dropped by a commit
0647bf564f1e ("Btrfs: improve forever loop when doing balance relocation"),
which is more than 10 years ago. Drop the argument and simplify the code.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/relocation.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index bd573a0ec270..22086e840801 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2281,8 +2281,7 @@ struct btrfs_root *select_one_root(struct btrfs_backref_node *node)
 }
 
 static noinline_for_stack
-u64 calcu_metadata_size(struct reloc_control *rc,
-			struct btrfs_backref_node *node, int reserve)
+u64 calcu_metadata_size(struct reloc_control *rc, struct btrfs_backref_node *node)
 {
 	struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
 	struct btrfs_backref_node *next = node;
@@ -2291,12 +2290,12 @@ u64 calcu_metadata_size(struct reloc_control *rc,
 	u64 num_bytes = 0;
 	int index = 0;
 
-	BUG_ON(reserve && node->processed);
+	BUG_ON(node->processed);
 
 	while (next) {
 		cond_resched();
 		while (1) {
-			if (next->processed && (reserve || next != node))
+			if (next->processed)
 				break;
 
 			num_bytes += fs_info->nodesize;
@@ -2324,7 +2323,7 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans,
 	int ret;
 	u64 tmp;
 
-	num_bytes = calcu_metadata_size(rc, node, 1) * 2;
+	num_bytes = calcu_metadata_size(rc, node) * 2;
 
 	trans->block_rsv = rc->block_rsv;
 	rc->reserved_bytes += num_bytes;
-- 
2.44.0


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

* Re: [PATCH] btrfs: drop unused argument of calcu_metadata_size()
  2024-04-24  6:38 [PATCH] btrfs: drop unused argument of calcu_metadata_size() Naohiro Aota
@ 2024-04-24  6:53 ` Qu Wenruo
  2024-04-24  7:57 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-04-24  6:53 UTC (permalink / raw)
  To: Naohiro Aota, linux-btrfs



在 2024/4/24 16:08, Naohiro Aota 写道:
> calcu_metadata_size() has a "reserve" argument, but the only caller always
> set it to "1". The other usage (reserve = 0) is dropped by a commit
> 0647bf564f1e ("Btrfs: improve forever loop when doing balance relocation"),
> which is more than 10 years ago. Drop the argument and simplify the code.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/relocation.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index bd573a0ec270..22086e840801 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -2281,8 +2281,7 @@ struct btrfs_root *select_one_root(struct btrfs_backref_node *node)
>   }
>
>   static noinline_for_stack
> -u64 calcu_metadata_size(struct reloc_control *rc,
> -			struct btrfs_backref_node *node, int reserve)
> +u64 calcu_metadata_size(struct reloc_control *rc, struct btrfs_backref_node *node)
>   {
>   	struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
>   	struct btrfs_backref_node *next = node;
> @@ -2291,12 +2290,12 @@ u64 calcu_metadata_size(struct reloc_control *rc,
>   	u64 num_bytes = 0;
>   	int index = 0;
>
> -	BUG_ON(reserve && node->processed);
> +	BUG_ON(node->processed);
>
>   	while (next) {
>   		cond_resched();
>   		while (1) {
> -			if (next->processed && (reserve || next != node))
> +			if (next->processed)
>   				break;
>
>   			num_bytes += fs_info->nodesize;
> @@ -2324,7 +2323,7 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans,
>   	int ret;
>   	u64 tmp;
>
> -	num_bytes = calcu_metadata_size(rc, node, 1) * 2;
> +	num_bytes = calcu_metadata_size(rc, node) * 2;
>
>   	trans->block_rsv = rc->block_rsv;
>   	rc->reserved_bytes += num_bytes;

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

* Re: [PATCH] btrfs: drop unused argument of calcu_metadata_size()
  2024-04-24  6:38 [PATCH] btrfs: drop unused argument of calcu_metadata_size() Naohiro Aota
  2024-04-24  6:53 ` Qu Wenruo
@ 2024-04-24  7:57 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2024-04-24  7:57 UTC (permalink / raw)
  To: Naohiro Aota, linux-btrfs

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

end of thread, other threads:[~2024-04-24  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24  6:38 [PATCH] btrfs: drop unused argument of calcu_metadata_size() Naohiro Aota
2024-04-24  6:53 ` Qu Wenruo
2024-04-24  7:57 ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).