public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/3] btrfs-progs: properly cleanup aborted transactions in check
Date: Wed, 6 Sep 2023 06:55:45 +0800	[thread overview]
Message-ID: <36a8f250-5545-45ce-8185-5451fbb0ebf4@gmx.com> (raw)
In-Reply-To: <d24c0b846b150fa9e5638fc90258bf2728f88351.1693945163.git.josef@toxicpanda.com>



On 2023/9/6 04:21, Josef Bacik wrote:
> 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.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

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

Although I'd say wouldn't it be better to make btrfs_abort_transaction()
more standalone?

It's pretty instinctive to think btrfs_abort_transaction() should handle
everything.

Thanks,
Qu
> ---
>   check/main.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/check/main.c b/check/main.c
> index c99092a2..1d5f570a 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -3114,6 +3114,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;
>   			}
>
> @@ -8011,8 +8012,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;
>   }
>
> @@ -8223,8 +8226,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;

  reply	other threads:[~2023-09-05 22:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 20:21 [PATCH 0/3] btrfs-progs: add eb leak detection and fixes Josef Bacik
2023-09-05 20:21 ` [PATCH 1/3] btrfs-progs: cleanup dirty buffers on transaction abort Josef Bacik
2023-09-05 22:53   ` Qu Wenruo
2023-09-05 20:21 ` [PATCH 2/3] btrfs-progs: properly cleanup aborted transactions in check Josef Bacik
2023-09-05 22:55   ` Qu Wenruo [this message]
2023-09-06 13:34     ` Josef Bacik
2023-09-05 20:21 ` [PATCH 3/3] btrfs-progs: add extent buffer leak detection to make test Josef Bacik
2023-09-05 20:49   ` David Sterba
2023-09-06 13:52     ` Josef Bacik
2023-09-05 22:57   ` Qu Wenruo
2023-09-07 13:32     ` David Sterba
2023-09-08 12:08 ` [PATCH 0/3] btrfs-progs: add eb leak detection and fixes David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36a8f250-5545-45ce-8185-5451fbb0ebf4@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox