From: Filipe Manana Date: Fri, 16 May 2025 16:07:40 +0000 (+0100) Subject: btrfs: unfold transaction aborts at btrfs_create_new_inode() X-Git-Tag: block-6.17-20250808~77^2~208 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=3f757b56f1c4579fe32b810bce1d39f202964412;p=linux-block.git btrfs: unfold transaction aborts at btrfs_create_new_inode() Instead of having a common btrfs_abort_transaction() call for when either btrfs_orphan_add() failed or when btrfs_add_link() failed, move the btrfs_abort_transaction() to happen immediately after each one of those calls, so that when analysing a stack trace with a transaction abort we know which call failed. Reviewed-by: Boris Burkov Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fc66872b4c74..bb938d5c0c9b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6610,13 +6610,17 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans, if (args->orphan) { ret = btrfs_orphan_add(trans, BTRFS_I(inode)); + if (ret) { + btrfs_abort_transaction(trans, ret); + goto discard; + } } else { ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name, 0, BTRFS_I(inode)->dir_index); - } - if (ret) { - btrfs_abort_transaction(trans, ret); - goto discard; + if (ret) { + btrfs_abort_transaction(trans, ret); + goto discard; + } } return 0;