btrfs-progs: handle error if btrfs_write_one_block_group() failed

Just break loop and return the error code if failed.  Functions in the
call chain are able to handle it.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Su Yue <Damenly_Su@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Su Yue 2019-12-18 13:18:40 +08:00 committed by David Sterba
parent 7e26b93932
commit 764c8dea72
2 changed files with 6 additions and 2 deletions

View File

@ -1596,9 +1596,11 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans)
cache = (struct btrfs_block_group_cache *)(unsigned long)ptr; cache = (struct btrfs_block_group_cache *)(unsigned long)ptr;
ret = write_one_cache_group(trans, path, cache); ret = write_one_cache_group(trans, path, cache);
if (ret)
break;
} }
btrfs_free_path(path); btrfs_free_path(path);
return 0; return ret;
} }
static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info, static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,

View File

@ -77,7 +77,9 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
&root->root_item); &root->root_item);
if (ret < 0) if (ret < 0)
return ret; return ret;
btrfs_write_dirty_block_groups(trans); ret = btrfs_write_dirty_block_groups(trans);
if (ret)
return ret;
} }
return 0; return 0;
} }