diff mbox series

[6/8] btrfs: relocation: return bool from btrfs_should_ignore_reloc_root

Message ID 54a6cbc4c91d872ec7eb9d1f7c1240d137fcfe5b.1695380646.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series Minor cleanups in relocation.c | expand

Commit Message

David Sterba Sept. 22, 2023, 11:07 a.m. UTC
btrfs_should_ignore_reloc_root() is a predicate so it should return
bool.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/relocation.c | 19 +++++++++----------
 fs/btrfs/relocation.h |  2 +-
 2 files changed, 10 insertions(+), 11 deletions(-)

Comments

Johannes Thumshirn Sept. 22, 2023, 12:36 p.m. UTC | #1
On 22.09.23 13:14, David Sterba wrote:
> btrfs_should_ignore_reloc_root() is a predicate so it should return
> bool.

Btw both callsites also check for btrfs_backref_cache::is_reloc, so 
maybe that check can be merged into btrfs_should_ignore_reloc_root() as 
well?

Anyways,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
David Sterba Sept. 22, 2023, 6:35 p.m. UTC | #2
On Fri, Sep 22, 2023 at 12:36:31PM +0000, Johannes Thumshirn wrote:
> On 22.09.23 13:14, David Sterba wrote:
> > btrfs_should_ignore_reloc_root() is a predicate so it should return
> > bool.
> 
> Btw both callsites also check for btrfs_backref_cache::is_reloc, so 
> maybe that check can be merged into btrfs_should_ignore_reloc_root() as 
> well?

The helper is related to the root, for the is_reloc it would also have
to take the cache which looks like a separate thing. I think it would
obscure the condition.
Qu Wenruo Sept. 22, 2023, 10:32 p.m. UTC | #3
On 2023/9/22 20:37, David Sterba wrote:
> btrfs_should_ignore_reloc_root() is a predicate so it should return
> bool.
>
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks,
Qu
> ---
>   fs/btrfs/relocation.c | 19 +++++++++----------
>   fs/btrfs/relocation.h |  2 +-
>   2 files changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 75463377f418..d1dcbb15baa7 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -325,31 +325,30 @@ static bool have_reloc_root(struct btrfs_root *root)
>   	return true;
>   }
>
> -int btrfs_should_ignore_reloc_root(struct btrfs_root *root)
> +bool btrfs_should_ignore_reloc_root(struct btrfs_root *root)
>   {
>   	struct btrfs_root *reloc_root;
>
>   	if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
> -		return 0;
> +		return false;
>
>   	/* This root has been merged with its reloc tree, we can ignore it */
>   	if (reloc_root_is_dead(root))
> -		return 1;
> +		return true;
>
>   	reloc_root = root->reloc_root;
>   	if (!reloc_root)
> -		return 0;
> +		return false;
>
>   	if (btrfs_header_generation(reloc_root->commit_root) ==
>   	    root->fs_info->running_transaction->transid)
> -		return 0;
> +		return false;
>   	/*
> -	 * if there is reloc tree and it was created in previous
> -	 * transaction backref lookup can find the reloc tree,
> -	 * so backref node for the fs tree root is useless for
> -	 * relocation.
> +	 * If there is reloc tree and it was created in previous transaction
> +	 * backref lookup can find the reloc tree, so backref node for the fs
> +	 * tree root is useless for relocation.
>   	 */
> -	return 1;
> +	return true;
>   }
>
>   /*
> diff --git a/fs/btrfs/relocation.h b/fs/btrfs/relocation.h
> index 77d69f6ae967..af749c780b4e 100644
> --- a/fs/btrfs/relocation.h
> +++ b/fs/btrfs/relocation.h
> @@ -18,7 +18,7 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
>   			      struct btrfs_pending_snapshot *pending);
>   int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info);
>   struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
> -int btrfs_should_ignore_reloc_root(struct btrfs_root *root);
> +bool btrfs_should_ignore_reloc_root(struct btrfs_root *root);
>   u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info);
>
>   #endif
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 75463377f418..d1dcbb15baa7 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -325,31 +325,30 @@  static bool have_reloc_root(struct btrfs_root *root)
 	return true;
 }
 
-int btrfs_should_ignore_reloc_root(struct btrfs_root *root)
+bool btrfs_should_ignore_reloc_root(struct btrfs_root *root)
 {
 	struct btrfs_root *reloc_root;
 
 	if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
-		return 0;
+		return false;
 
 	/* This root has been merged with its reloc tree, we can ignore it */
 	if (reloc_root_is_dead(root))
-		return 1;
+		return true;
 
 	reloc_root = root->reloc_root;
 	if (!reloc_root)
-		return 0;
+		return false;
 
 	if (btrfs_header_generation(reloc_root->commit_root) ==
 	    root->fs_info->running_transaction->transid)
-		return 0;
+		return false;
 	/*
-	 * if there is reloc tree and it was created in previous
-	 * transaction backref lookup can find the reloc tree,
-	 * so backref node for the fs tree root is useless for
-	 * relocation.
+	 * If there is reloc tree and it was created in previous transaction
+	 * backref lookup can find the reloc tree, so backref node for the fs
+	 * tree root is useless for relocation.
 	 */
-	return 1;
+	return true;
 }
 
 /*
diff --git a/fs/btrfs/relocation.h b/fs/btrfs/relocation.h
index 77d69f6ae967..af749c780b4e 100644
--- a/fs/btrfs/relocation.h
+++ b/fs/btrfs/relocation.h
@@ -18,7 +18,7 @@  int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
 			      struct btrfs_pending_snapshot *pending);
 int btrfs_should_cancel_balance(struct btrfs_fs_info *fs_info);
 struct btrfs_root *find_reloc_root(struct btrfs_fs_info *fs_info, u64 bytenr);
-int btrfs_should_ignore_reloc_root(struct btrfs_root *root);
+bool btrfs_should_ignore_reloc_root(struct btrfs_root *root);
 u64 btrfs_get_reloc_bg_bytenr(struct btrfs_fs_info *fs_info);
 
 #endif