]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: stop checking for -EEXIST return value from btrfs_uuid_tree_add()
authorFilipe Manana <fdmanana@suse.com>
Tue, 24 Feb 2026 15:13:32 +0000 (15:13 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:55:59 +0000 (18:55 +0200)
We never return -EEXIST from btrfs_uuid_tree_add(), if the item already
exists we extend it, so it's pointless to check for such return value.

Furthermore, in create_pending_snapshot(), the logic is completely broken.
The goal was to not error out and abort the transaction in case of -EEXIST
but we left 'ret' with the -EEXIST value, so we end up setting
pending->error to -EEXIST and return that error up the call chain up to
btrfs_commit_transaction(), which will abort the transaction.

Reviewed-by: Boris Burkov <boris@bur.io>
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>
fs/btrfs/ioctl.c
fs/btrfs/transaction.c

index f2503668ce9deaefd8ecf4a02bda0c65d0f419be..a4d715bbed57ba576671e7a5666924b3bceb3bc8 100644 (file)
@@ -3928,7 +3928,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
                ret = btrfs_uuid_tree_add(trans, sa->uuid,
                                          BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                          btrfs_root_id(root));
-               if (unlikely(ret < 0 && ret != -EEXIST)) {
+               if (unlikely(ret < 0)) {
                        btrfs_abort_transaction(trans, ret);
                        btrfs_end_transaction(trans);
                        goto out;
index 36d0f05b06e025774320ea5e4ed83f9cd4bade8b..13e59ce3f5fbad9da792ff2f1bf58ae1abdaa9d4 100644 (file)
@@ -1918,7 +1918,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
                 */
                if (ret == -EOVERFLOW)
                        ret = 0;
-               if (unlikely(ret && ret != -EEXIST)) {
+               if (unlikely(ret)) {
                        btrfs_abort_transaction(trans, ret);
                        goto fail;
                }