From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 4/4] btrfs: move transaction aborts to the error site in add_to_free_space_tree()
Date: Wed, 30 Apr 2025 18:45:21 +0200 [thread overview]
Message-ID: <28545fbbdf3126ac09889df38414ef17f5c85284.1746031378.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1746031378.git.dsterba@suse.com>
Transaction aborts should be done next to the place the error happens,
which was not done in add_to_free_space_tree().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/free-space-tree.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index ffe98bea6927f9..0c573d46639ae9 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1045,6 +1045,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path();
if (!path) {
ret = -ENOMEM;
+ btrfs_abort_transaction(trans, ret);
goto out;
}
@@ -1052,18 +1053,19 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
if (!block_group) {
DEBUG_WARN("no block group found for start=%llu", start);
ret = -ENOENT;
+ btrfs_abort_transaction(trans, ret);
goto out;
}
mutex_lock(&block_group->free_space_lock);
ret = __add_to_free_space_tree(trans, block_group, path, start, size);
mutex_unlock(&block_group->free_space_lock);
+ if (ret)
+ btrfs_abort_transaction(trans, ret);
btrfs_put_block_group(block_group);
out:
btrfs_free_path(path);
- if (ret)
- btrfs_abort_transaction(trans, ret);
return ret;
}
--
2.49.0
next prev parent reply other threads:[~2025-04-30 16:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 16:45 [PATCH 0/4] Transaction aborts in free-space-tree.c David Sterba
2025-04-30 16:45 ` [PATCH 1/4] btrfs: move transaction aborts to the error site in convert_free_space_to_bitmaps() David Sterba
2025-04-30 16:45 ` [PATCH 2/4] btrfs: move transaction aborts to the error site in convert_free_space_to_extents() David Sterba
2025-04-30 16:45 ` [PATCH 3/4] btrfs: move transaction aborts to the error site in remove_from_free_space_tree() David Sterba
2025-04-30 16:45 ` David Sterba [this message]
2025-05-02 13:15 ` [PATCH 0/4] Transaction aborts in free-space-tree.c Daniel Vacek
2025-05-02 13:24 ` David Sterba
2025-05-02 13:32 ` Daniel Vacek
2025-05-02 14:31 ` David Sterba
2025-05-02 15:10 ` Daniel Vacek
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=28545fbbdf3126ac09889df38414ef17f5c85284.1746031378.git.dsterba@suse.com \
--to=dsterba@suse.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