From 855622bd946104b52dbdd896e734b85abe4e78cf Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 5 Sep 2023 16:21:52 -0400 Subject: [PATCH] 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 Signed-off-by: Josef Bacik Signed-off-by: David Sterba --- check/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/check/main.c b/check/main.c index 5e4e51af..22495452 100644 --- a/check/main.c +++ b/check/main.c @@ -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;