Re: [PATCH] btrfs: remove unnecessary if judge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 21.05.2018 12:32, Gu Jinxiang wrote:
> Since add_excluded_extent always returns 0,
> no need to judge ret.

This patch is conceptually wrong because:

a). Currently exclude_super_stripes is in fact buggy since it calls
set_extent_bits which *may* fail, yet the return value is completely
ignored. I think the best fix is to actually handle the failures from
set_extent_bit inside add_excluded_extent and actually propagate them to
callers.

b) If it's deemed appropriate (which I think it's not) to ignore the
return value then add_excluded_extent should be turned into a function
which returns void.


> 
> Signed-off-by: Gu Jinxiang <gujx@xxxxxxxxxxxxxx>
> ---
>  fs/btrfs/extent-tree.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 75cfb80d2551..4d876b32e136 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -249,8 +249,6 @@ static int exclude_super_stripes(struct btrfs_fs_info *fs_info,
>  		cache->bytes_super += stripe_len;
>  		ret = add_excluded_extent(fs_info, cache->key.objectid,
>  					  stripe_len);
> -		if (ret)
> -			return ret;
>  	}
>  
>  	for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
> @@ -282,10 +280,6 @@ static int exclude_super_stripes(struct btrfs_fs_info *fs_info,
>  
>  			cache->bytes_super += len;
>  			ret = add_excluded_extent(fs_info, start, len);
> -			if (ret) {
> -				kfree(logical);
> -				return ret;
> -			}
>  		}
>  
>  		kfree(logical);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux