From: David Sterba Date: Tue, 14 Apr 2026 15:30:32 +0000 (+0200) Subject: btrfs: lift assertions to beginning of insert_delayed_ref() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54ce0b1d59890464268e3583cdf75482723957e4;p=thirdparty%2Flinux.git btrfs: lift assertions to beginning of insert_delayed_ref() There are only two possible types of the delayed ref action, this can be verified at the beginning for the whole function and not just one block. Replace the assertion with a debugging warning just in case. Reviewed-by: Johannes Thumshirn Signed-off-by: David Sterba --- diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 605858c2d9a95..8bc1929237f70 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -615,6 +615,9 @@ static bool insert_delayed_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_node *exist; int mod; + ASSERT(ref->action == BTRFS_ADD_DELAYED_REF || + ref->action == BTRFS_DROP_DELAYED_REF); + spin_lock(&href->lock); exist = tree_insert(&href->ref_tree, ref); if (!exist) { @@ -641,7 +644,7 @@ static bool insert_delayed_ref(struct btrfs_trans_handle *trans, ASSERT(!list_empty(&exist->add_list)); list_del_init(&exist->add_list); } else { - ASSERT(0); + DEBUG_WARN(); } } else mod = -ref->ref_mod;