diff mbox series

[v3,43/54] btrfs: remove the extent item sanity checks in relocate_block_group

Message ID 09013ee34800bd1bd6354254a1b6a29ddf68f09f.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:51 p.m. UTC
These checks are all taken care of for us by the tree checker code.

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

Comments

Qu Wenruo Dec. 3, 2020, 5:20 a.m. UTC | #1
On 2020/12/3 上午3:51, Josef Bacik wrote:
> These checks are all taken care of for us by the tree checker code.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Yeah! Finally see a day where tree-checker is involved in removing
duplicated checks.

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

Thanks,
Qu

> ---
>  fs/btrfs/relocation.c | 29 +----------------------------
>  1 file changed, 1 insertion(+), 28 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 3159f6517588..8f4f1e21c770 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3370,20 +3370,6 @@ static void unset_reloc_control(struct reloc_control *rc)
>  	mutex_unlock(&fs_info->reloc_mutex);
>  }
>  
> -static int check_extent_flags(u64 flags)
> -{
> -	if ((flags & BTRFS_EXTENT_FLAG_DATA) &&
> -	    (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
> -		return 1;
> -	if (!(flags & BTRFS_EXTENT_FLAG_DATA) &&
> -	    !(flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
> -		return 1;
> -	if ((flags & BTRFS_EXTENT_FLAG_DATA) &&
> -	    (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF))
> -		return 1;
> -	return 0;
> -}
> -
>  static noinline_for_stack
>  int prepare_to_relocate(struct reloc_control *rc)
>  {
> @@ -3435,7 +3421,6 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
>  	struct btrfs_path *path;
>  	struct btrfs_extent_item *ei;
>  	u64 flags;
> -	u32 item_size;
>  	int ret;
>  	int err = 0;
>  	int progress = 0;
> @@ -3484,19 +3469,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
>  
>  		ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
>  				    struct btrfs_extent_item);
> -		item_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
> -		if (item_size >= sizeof(*ei)) {
> -			flags = btrfs_extent_flags(path->nodes[0], ei);
> -			ret = check_extent_flags(flags);
> -			BUG_ON(ret);
> -		} else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
> -			err = -EINVAL;
> -			btrfs_print_v0_err(trans->fs_info);
> -			btrfs_abort_transaction(trans, err);
> -			break;
> -		} else {
> -			BUG();
> -		}
> +		flags = btrfs_extent_flags(path->nodes[0], ei);
>  
>  		if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
>  			ret = add_tree_block(rc, &key, path, &blocks);
>
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 3159f6517588..8f4f1e21c770 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3370,20 +3370,6 @@  static void unset_reloc_control(struct reloc_control *rc)
 	mutex_unlock(&fs_info->reloc_mutex);
 }
 
-static int check_extent_flags(u64 flags)
-{
-	if ((flags & BTRFS_EXTENT_FLAG_DATA) &&
-	    (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
-		return 1;
-	if (!(flags & BTRFS_EXTENT_FLAG_DATA) &&
-	    !(flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
-		return 1;
-	if ((flags & BTRFS_EXTENT_FLAG_DATA) &&
-	    (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF))
-		return 1;
-	return 0;
-}
-
 static noinline_for_stack
 int prepare_to_relocate(struct reloc_control *rc)
 {
@@ -3435,7 +3421,6 @@  static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 	struct btrfs_path *path;
 	struct btrfs_extent_item *ei;
 	u64 flags;
-	u32 item_size;
 	int ret;
 	int err = 0;
 	int progress = 0;
@@ -3484,19 +3469,7 @@  static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 
 		ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
 				    struct btrfs_extent_item);
-		item_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
-		if (item_size >= sizeof(*ei)) {
-			flags = btrfs_extent_flags(path->nodes[0], ei);
-			ret = check_extent_flags(flags);
-			BUG_ON(ret);
-		} else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
-			err = -EINVAL;
-			btrfs_print_v0_err(trans->fs_info);
-			btrfs_abort_transaction(trans, err);
-			break;
-		} else {
-			BUG();
-		}
+		flags = btrfs_extent_flags(path->nodes[0], ei);
 
 		if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
 			ret = add_tree_block(rc, &key, path, &blocks);