btrfs: defrag: change BUG_ON to assertion in btrfs_defrag_leaves()
authorDavid Sterba <dsterba@suse.com>
Fri, 19 Jan 2024 19:15:41 +0000 (20:15 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:48 +0000 (16:24 +0100)
The BUG_ON verifies a condition that should be guaranteed by the correct
use of the path search (with keep_locks and lowest_level set), an
assertion is the suitable check.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/defrag.c

index eb62ff490c48ca3efe403927dd57fe44b9d67024..6f49de3ec92f8969296c148220fdae94ed7a8f69 100644 (file)
@@ -520,7 +520,7 @@ static int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
         * keep_locks set and lowest_level is 1, regardless of the value of
         * path->slots[1].
         */
-       BUG_ON(path->locks[1] == 0);
+       ASSERT(path->locks[1] != 0);
        ret = btrfs_realloc_node(trans, root,
                                 path->nodes[1], 0,
                                 &last_ret,