mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yangtao Li <frank.li@vivo.com>
To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yangtao Li <frank.li@vivo.com>
Subject: [PATCH 4/4] btrfs: Fix transaction abort during failure in del_balance_item()
Date: Tue,  8 Apr 2025 06:29:33 -0600	[thread overview]
Message-ID: <20250408122933.121056-4-frank.li@vivo.com> (raw)
In-Reply-To: <20250408122933.121056-1-frank.li@vivo.com>

Handle errors by adding explicit btrfs_abort_transaction
and btrfs_end_transaction calls.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/btrfs/volumes.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 347c475028e0..23739d18d833 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3777,7 +3777,7 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
 	struct btrfs_trans_handle *trans;
 	BTRFS_PATH_AUTO_FREE(path);
 	struct btrfs_key key;
-	int ret, err;
+	int ret;
 
 	path = btrfs_alloc_path();
 	if (!path)
@@ -3800,10 +3800,13 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
 	}
 
 	ret = btrfs_del_item(trans, root, path);
+	if (ret)
+		goto out;
+
+	return btrfs_commit_transaction(trans);
 out:
-	err = btrfs_commit_transaction(trans);
-	if (err && !ret)
-		ret = err;
+	btrfs_abort_transaction(trans, ret);
+	btrfs_end_transaction(trans);
 	return ret;
 }
 
-- 
2.39.0


  parent reply	other threads:[~2025-04-08 12:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 12:29 [PATCH 1/4] btrfs: use BTRFS_PATH_AUTO_FREE in insert_balance_item() Yangtao Li
2025-04-08 12:29 ` [PATCH 2/4] btrfs: use BTRFS_PATH_AUTO_FREE in del_balance_item() Yangtao Li
2025-04-08 14:47   ` Filipe Manana
2025-04-08 12:29 ` [PATCH 3/4] btrfs: Fix transaction abort during failure in insert_balance_item() Yangtao Li
2025-04-08 14:50   ` Filipe Manana
2025-04-08 12:29 ` Yangtao Li [this message]
2025-04-08 14:53   ` [PATCH 4/4] btrfs: Fix transaction abort during failure in del_balance_item() Filipe Manana
2025-04-08 23:04     ` David Sterba
2025-04-09  9:50       ` Filipe Manana
2025-04-08 14:44 ` [PATCH 1/4] btrfs: use BTRFS_PATH_AUTO_FREE in insert_balance_item() Filipe Manana
2025-04-08 17:36   ` Daniel Vacek
2025-04-08 17:40     ` Filipe Manana
2025-04-08 17:47       ` Daniel Vacek
2025-04-08 17:52         ` Filipe Manana
2025-04-08 18:00           ` Daniel Vacek
2025-04-09 12:19   ` 回复: " 李扬韬
2025-04-08 22:47 ` David Sterba
2025-04-09  9:45   ` Filipe Manana

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=20250408122933.121056-4-frank.li@vivo.com \
    --to=frank.li@vivo.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®