Commit cb73493c authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba
Browse files

btrfs: avoid transaction commit on error in del_balance_item()



There's no point in committing the transaction if we failed to delete the
item, since we haven't done anything before. Also stop using two variables
for tracking the return value and use only 'ret'.

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6d0f25cd
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -3691,7 +3691,7 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
	struct btrfs_trans_handle *trans;
	struct btrfs_path *path;
	struct btrfs_key key;
	int ret, err;
	int ret;

	path = btrfs_alloc_path();
	if (!path)
@@ -3718,9 +3718,11 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
	ret = btrfs_del_item(trans, root, path);
out:
	btrfs_free_path(path);
	err = btrfs_commit_transaction(trans);
	if (err && !ret)
		ret = err;
	if (ret == 0)
		ret = btrfs_commit_transaction(trans);
	else
		btrfs_end_transaction(trans);

	return ret;
}