From: Filipe Manana Date: Tue, 24 Feb 2026 15:13:32 +0000 (+0000) Subject: btrfs: stop checking for -EEXIST return value from btrfs_uuid_tree_add() X-Git-Tag: v7.1-rc1~231^2~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aa1788ff09fba1db7d66b38a20051f0997b9cb9;p=thirdparty%2Fkernel%2Flinux.git btrfs: stop checking for -EEXIST return value from btrfs_uuid_tree_add() 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 Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index f2503668ce9de..a4d715bbed57b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -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; diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 36d0f05b06e02..13e59ce3f5fba 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -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; }