btrfs-progs: properly cleanup aborted transactions in check

There are several places that we call btrfs_abort_transaction() in a
failure case, but never call btrfs_commit_transaction().  This leaks the
trans handle and the associated extent buffers and such.  Fix all these
sites by making sure we call btrfs_commit_transaction() after we call
btrfs_abort_transaction() to make sure all the appropriate cleanup is
done.  This gets rid of the leaked extent buffer errors.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2023-09-05 16:21:52 -04:00 committed by David Sterba
parent 2a34fd3892
commit 855622bd94
1 changed files with 8 additions and 2 deletions

View File

@ -3116,6 +3116,7 @@ static int check_inode_recs(struct btrfs_root *root,
ret = btrfs_make_root_dir(trans, root, root_dirid);
if (ret < 0) {
btrfs_abort_transaction(trans, ret);
btrfs_commit_transaction(trans, root);
return ret;
}
@ -8022,8 +8023,10 @@ static int repair_extent_item_generation(struct extent_record *rec)
rec->generation = new_gen;
out:
btrfs_release_path(&path);
if (ret < 0)
if (ret < 0) {
btrfs_abort_transaction(trans, ret);
btrfs_commit_transaction(trans, extent_root);
}
return ret;
}
@ -8242,8 +8245,11 @@ repair_abort:
}
ret = btrfs_fix_block_accounting(trans);
if (ret)
if (ret) {
btrfs_abort_transaction(trans, ret);
btrfs_commit_transaction(trans, root);
goto repair_abort;
}
ret = btrfs_commit_transaction(trans, root);
if (ret)
goto repair_abort;