]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: fix incorrect comparison for delayed refs
authorJosef Bacik <josef@toxicpanda.com>
Wed, 13 Nov 2024 16:05:13 +0000 (11:05 -0500)
committerDavid Sterba <dsterba@suse.com>
Thu, 14 Nov 2024 15:11:02 +0000 (16:11 +0100)
When I reworked delayed ref comparison in cf4f04325b2b ("btrfs: move
->parent and ->ref_root into btrfs_delayed_ref_node"), I made a mistake
and returned -1 for the case where ref1->ref_root was > than
ref2->ref_root.  This is a subtle bug that can result in improper
delayed ref running order, which can result in transaction aborts.

Fixes: cf4f04325b2b ("btrfs: move ->parent and ->ref_root into btrfs_delayed_ref_node")
CC: stable@vger.kernel.org # 6.10+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-ref.c

index 65d841d7142c0765e1c7c612ac15a3c94ad52ac1..cab94d141f66295e45e988af2589c8bf976e9da7 100644 (file)
@@ -298,7 +298,7 @@ static int comp_refs(struct btrfs_delayed_ref_node *ref1,
                if (ref1->ref_root < ref2->ref_root)
                        return -1;
                if (ref1->ref_root > ref2->ref_root)
-                       return -1;
+                       return 1;
                if (ref1->type == BTRFS_EXTENT_DATA_REF_KEY)
                        ret = comp_data_refs(ref1, ref2);
        }