Use the conditional warning instead of typing the whole condition.
Optional message is printed where it seems clear what could be the
problem.
Conversion is left out in btree_csum_one_bio() because of the additional
condition.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
                goto release;
        }
        if (path->slots[0] == 0) {
-               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+               DEBUG_WARN();
                ret = -EUCLEAN;
                goto release;
        }
 
        set_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags);
 
        if (btrfs_check_quota_leak(fs_info)) {
-               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+               DEBUG_WARN("qgroup reserved space leaked");
                btrfs_err(fs_info, "qgroup reserved space leaked");
        }
 
 
 
                /* Check if there are any CHUNK_* bits left */
                if (start > device->total_bytes) {
-                       WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+                       DEBUG_WARN();
                        btrfs_warn_in_rcu(fs_info,
 "ignoring attempt to trim beyond device size: offset %llu length %llu device %s device size %llu",
                                          start, end - start + 1,
 
        btrfs_warn(eb->fs_info,
                "access to eb bytenr %llu len %u out of range start %lu len %lu",
                eb->start, eb->len, start, len);
-       WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+       DEBUG_WARN();
 
        return true;
 }
 
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
        if (!btrfs_inode_can_compress(inode)) {
-               WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
-                       KERN_ERR "BTRFS: unexpected compression for ino %llu\n",
-                       btrfs_ino(inode));
+               DEBUG_WARN("BTRFS: unexpected compression for ino %llu", btrfs_ino(inode));
                return 0;
        }
 
         * We should not hit such out-of-band dirty folios anymore.
         */
        if (IS_ENABLED(CONFIG_BTRFS_EXPERIMENTAL)) {
-               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+               DEBUG_WARN();
                btrfs_err_rl(fs_info,
        "root %lld ino %llu folio %llu is marked dirty without notifying the fs",
                             BTRFS_I(inode)->root->root_key.objectid,
 
        if (qgroup->rsv.values[BTRFS_QGROUP_RSV_DATA] ||
            qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC] ||
            qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS]) {
-               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+               DEBUG_WARN();
                btrfs_warn_rl(fs_info,
 "to be deleted qgroup %u/%llu has non-zero numbers, data %llu meta prealloc %llu meta pertrans %llu",
                              btrfs_qgroup_level(qgroup->qgroupid),
            !(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)) {
                if (qgroup->rfer || qgroup->excl ||
                    qgroup->rfer_cmpr || qgroup->excl_cmpr) {
-                       WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+                       DEBUG_WARN();
                        btrfs_warn_rl(fs_info,
 "to be deleted qgroup %u/%llu has non-zero numbers, rfer %llu rfer_cmpr %llu excl %llu excl_cmpr %llu",
                                      btrfs_qgroup_level(qgroup->qgroupid),
                                 * Marking qgroup inconsistent should be enough
                                 * for end users.
                                 */
-                               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+                               DEBUG_WARN("duplicated but mismatched entry found");
                                ret = -EEXIST;
                        }
                        kfree(block);
 
 
        found_level = btrfs_header_level(eb);
        if (unlikely(found_level != check->level)) {
-               WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
-                    KERN_ERR "BTRFS: tree level check failed\n");
+               DEBUG_WARN();
                btrfs_err(fs_info,
 "tree level mismatch detected, bytenr=%llu level expected=%u has=%u",
                          eb->start, check->level, found_level);
                btrfs_err(fs_info,
                "invalid tree nritems, bytenr=%llu nritems=0 expect >0",
                          eb->start);
-               WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+               DEBUG_WARN();
                return -EUCLEAN;
        }
 
 
        ret = btrfs_comp_cpu_keys(&check->first_key, &found_key);
        if (unlikely(ret)) {
-               WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
-                    KERN_ERR "BTRFS: tree first key check failed\n");
+               DEBUG_WARN();
                btrfs_err(fs_info,
 "tree first key mismatch detected, bytenr=%llu parent_transid=%llu key expected=(%llu,%u,%llu) has=(%llu,%u,%llu)",
                          eb->start, check->transid, check->first_key.objectid,