[v2] btrfs: handle failures of set_extent_bits in add_excluded_extent
diff mbox

Message ID 1527046667-19550-1-git-send-email-gujx@cn.fujitsu.com
State New
Headers show

Commit Message

Gu Jinxiang May 23, 2018, 3:37 a.m. UTC
set_extent_bits may fail, return the result in add_excluded_extent.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Changelog:
v2-v1:
 1.remove goto to make the function run linearly.
 2.change commit description not pointing out the failure detail,
   since set_extent_bits's failure type may be added.
---
 fs/btrfs/extent-tree.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Nikolay Borisov May 23, 2018, 6:13 a.m. UTC | #1
On 23.05.2018 06:37, Gu Jinxiang wrote:
> set_extent_bits may fail, return the result in add_excluded_extent.
> 
> Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>

Reviewed-by: Nikolay Borisov <nborisvo@suse.com>

> Changelog:
> v2-v1:
>  1.remove goto to make the function run linearly.
>  2.change commit description not pointing out the failure detail,
>    since set_extent_bits's failure type may be added.

The changelog should really go under the scissors line but no need to
resend.

> ---
>  fs/btrfs/extent-tree.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 75cfb80d2551..65ef3456fa62 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -215,11 +215,15 @@ static int add_excluded_extent(struct btrfs_fs_info *fs_info,
>  			       u64 start, u64 num_bytes)
>  {
>  	u64 end = start + num_bytes - 1;
> -	set_extent_bits(&fs_info->freed_extents[0],
> +	int ret = 0;
> +
> +	ret = set_extent_bits(&fs_info->freed_extents[0],
>  			start, end, EXTENT_UPTODATE);
> -	set_extent_bits(&fs_info->freed_extents[1],
> +	if (ret)
> +		return ret;
> +	ret = set_extent_bits(&fs_info->freed_extents[1],
>  			start, end, EXTENT_UPTODATE);
> -	return 0;
> +	return ret;
>  }
>  
>  static void free_excluded_extents(struct btrfs_fs_info *fs_info,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 75cfb80d2551..65ef3456fa62 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -215,11 +215,15 @@  static int add_excluded_extent(struct btrfs_fs_info *fs_info,
 			       u64 start, u64 num_bytes)
 {
 	u64 end = start + num_bytes - 1;
-	set_extent_bits(&fs_info->freed_extents[0],
+	int ret = 0;
+
+	ret = set_extent_bits(&fs_info->freed_extents[0],
 			start, end, EXTENT_UPTODATE);
-	set_extent_bits(&fs_info->freed_extents[1],
+	if (ret)
+		return ret;
+	ret = set_extent_bits(&fs_info->freed_extents[1],
 			start, end, EXTENT_UPTODATE);
-	return 0;
+	return ret;
 }
 
 static void free_excluded_extents(struct btrfs_fs_info *fs_info,