diff mbox series

[v3,09/54] btrfs: don't clear ret in btrfs_start_dirty_block_groups

Message ID 89d8fc9f58723113f0f6685d67480541044839d3.1606938211.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Cleanup error handling in relocation | expand

Commit Message

Josef Bacik Dec. 2, 2020, 7:50 p.m. UTC
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/block-group.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Qu Wenruo Dec. 3, 2020, 2:13 a.m. UTC | #1
On 2020/12/3 上午3:50, Josef Bacik wrote:
> 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.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/block-group.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 52f2198d44c9..0886e81e5540 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -2669,7 +2669,8 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans)
>  	 * 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);
>
Johannes Thumshirn Dec. 3, 2020, 8:58 a.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 52f2198d44c9..0886e81e5540 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2669,7 +2669,8 @@  int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans)
 	 * 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);