From: Josef Bacik Date: Wed, 16 Dec 2020 16:22:17 +0000 (-0500) Subject: btrfs: don't clear ret in btrfs_start_dirty_block_groups X-Git-Tag: v5.11-rc5~37^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34d1eb0e599875064955a74712f08ff14c8e3d5f;p=thirdparty%2Fkernel%2Flinux.git btrfs: don't clear ret in btrfs_start_dirty_block_groups If we fail to update a block group item in the loop we'll break, however we'll do btrfs_run_delayed_refs and lose our error value in ret, and thus not clean up properly. Fix this by only running the delayed refs if there was no failure. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 52f2198d44c95..0886e81e55402 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2669,7 +2669,8 @@ again: * Go through delayed refs for all the stuff we've just kicked off * and then loop back (just once) */ - ret = btrfs_run_delayed_refs(trans, 0); + if (!ret) + ret = btrfs_run_delayed_refs(trans, 0); if (!ret && loops == 0) { loops++; spin_lock(&cur_trans->dirty_bgs_lock);