[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250408122933.121056-4-frank.li@vivo.com>
Date: Tue, 8 Apr 2025 06:29:33 -0600
From: Yangtao Li <frank.li@...o.com>
To: clm@...com,
josef@...icpanda.com,
dsterba@...e.com
Cc: linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yangtao Li <frank.li@...o.com>
Subject: [PATCH 4/4] btrfs: Fix transaction abort during failure in del_balance_item()
Handle errors by adding explicit btrfs_abort_transaction
and btrfs_end_transaction calls.
Signed-off-by: Yangtao Li <frank.li@...o.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
Powered by blists - more mailing lists