diff mbox series

[v3,36/54] btrfs: convert logic BUG_ON()'s in replace_path to ASSERT()'s

Message ID 118c78ea8991141e12c404753fa851e055de61ef.1606938211.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Cleanup error handling in relocation | expand

Commit Message

Josef Bacik Dec. 2, 2020, 7:50 p.m. UTC
A few BUG_ON()'s in replace_path are purely to keep us from making
logical mistakes, so replace them with ASSERT()'s.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/relocation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Qu Wenruo Dec. 3, 2020, 4:55 a.m. UTC | #1
On 2020/12/3 上午3:50, Josef Bacik wrote:
> A few BUG_ON()'s in replace_path are purely to keep us from making
> logical mistakes, so replace them with ASSERT()'s.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Indeed, these are really just to prevent developers passing wrong
parameters.

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

Thanks,
Qu
> ---
>  fs/btrfs/relocation.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 2fcb07bc8450..b872a64de8bb 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1202,8 +1202,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>  	int ret;
>  	int slot;
>  
> -	BUG_ON(src->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
> -	BUG_ON(dest->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
> +	ASSERT(src->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
> +	ASSERT(dest->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
>  
>  	last_snapshot = btrfs_root_last_snapshot(&src->root_item);
>  again:
> @@ -1234,7 +1234,7 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>  	parent = eb;
>  	while (1) {
>  		level = btrfs_header_level(parent);
> -		BUG_ON(level < lowest_level);
> +		ASSERT(level >= lowest_level);
>  
>  		ret = btrfs_bin_search(parent, &key, &slot);
>  		if (ret < 0)
>
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 2fcb07bc8450..b872a64de8bb 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1202,8 +1202,8 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 	int ret;
 	int slot;
 
-	BUG_ON(src->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
-	BUG_ON(dest->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
+	ASSERT(src->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
+	ASSERT(dest->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
 
 	last_snapshot = btrfs_root_last_snapshot(&src->root_item);
 again:
@@ -1234,7 +1234,7 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 	parent = eb;
 	while (1) {
 		level = btrfs_header_level(parent);
-		BUG_ON(level < lowest_level);
+		ASSERT(level >= lowest_level);
 
 		ret = btrfs_bin_search(parent, &key, &slot);
 		if (ret < 0)