btrfs: abort transaction on qgroup failures in create_pending_snapshot()

If we get an error when calling one of the qgroup functions, we jump to
the 'fail' label without aborting the transaction. This is not a bug as up
the call chain (transaction commit path), we will end up aborting the
transaction. However having the explicit transaction abort in
create_pending_snapshot() allows us to get a stack trace and log message
that tells us exactly where we failed, useful for troubleshooting, and
also adds consistency since in that function we abort the transaction in
every other error path.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2026-10-02 18:03:06 +01:00 committed by David Sterba
parent aad3c3c84f
commit 599fdbf3e3

View File

@ -1920,14 +1920,21 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* To co-operate with that hack, we do hack again.
* Or snapshot will be greatly slowed down by a subtree qgroup rescan
*/
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_FULL)
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_FULL) {
ret = qgroup_account_snapshot(trans, root, parent_root,
pending->inherit, objectid);
else if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_SIMPLE)
if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret);
goto fail;
}
} else if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_SIMPLE) {
ret = btrfs_qgroup_inherit(trans, btrfs_root_id(root), objectid,
btrfs_root_id(parent_root), pending->inherit);
if (unlikely(ret < 0))
goto fail;
if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret);
goto fail;
}
}
ret = btrfs_insert_dir_item(trans, &fname.disk_name,
parent_inode, &key, BTRFS_FT_DIR, index, NULL);