linux/fs/btrfs/messages.h

/* SPDX-License-Identifier: GPL-2.0 */

#ifndef BTRFS_MESSAGES_H
#define BTRFS_MESSAGES_H

#include <linux/types.h>
#include <linux/printk.h>
#include <linux/bug.h>

struct btrfs_fs_info;

/*
 * We want to be able to override this in btrfs-progs.
 */
#ifdef __KERNEL__

static inline __printf(2, 3) __cold
void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
{}

#endif

#ifdef CONFIG_PRINTK

#define btrfs_printk(fs_info, fmt, args...)

__printf(2, 3)
__cold
void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);

#else

#define btrfs_printk
#endif

#define btrfs_emerg(fs_info, fmt, args...)
#define btrfs_alert(fs_info, fmt, args...)
#define btrfs_crit(fs_info, fmt, args...)
#define btrfs_err(fs_info, fmt, args...)
#define btrfs_warn(fs_info, fmt, args...)
#define btrfs_notice(fs_info, fmt, args...)
#define btrfs_info(fs_info, fmt, args...)

/*
 * Wrappers that use printk_in_rcu
 */
#define btrfs_emerg_in_rcu(fs_info, fmt, args...)
#define btrfs_alert_in_rcu(fs_info, fmt, args...)
#define btrfs_crit_in_rcu(fs_info, fmt, args...)
#define btrfs_err_in_rcu(fs_info, fmt, args...)
#define btrfs_warn_in_rcu(fs_info, fmt, args...)
#define btrfs_notice_in_rcu(fs_info, fmt, args...)
#define btrfs_info_in_rcu(fs_info, fmt, args...)

/*
 * Wrappers that use a ratelimited printk_in_rcu
 */
#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_alert_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_err_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_notice_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_info_rl_in_rcu(fs_info, fmt, args...)

/*
 * Wrappers that use a ratelimited printk
 */
#define btrfs_emerg_rl(fs_info, fmt, args...)
#define btrfs_alert_rl(fs_info, fmt, args...)
#define btrfs_crit_rl(fs_info, fmt, args...)
#define btrfs_err_rl(fs_info, fmt, args...)
#define btrfs_warn_rl(fs_info, fmt, args...)
#define btrfs_notice_rl(fs_info, fmt, args...)
#define btrfs_info_rl(fs_info, fmt, args...)

#if defined(CONFIG_DYNAMIC_DEBUG)
#define btrfs_debug(fs_info, fmt, args...)
#define btrfs_debug_in_rcu(fs_info, fmt, args...)
#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...)
#define btrfs_debug_rl(fs_info, fmt, args...)
#elif defined(DEBUG)
#define btrfs_debug
#define btrfs_debug_in_rcu
#define btrfs_debug_rl_in_rcu
#define btrfs_debug_rl
#else
#define btrfs_debug
#define btrfs_debug_in_rcu
#define btrfs_debug_rl_in_rcu
#define btrfs_debug_rl
#endif

#define btrfs_printk_in_rcu(fs_info, fmt, args...)

#define btrfs_no_printk_in_rcu(fs_info, fmt, args...)

#define btrfs_printk_ratelimited(fs_info, fmt, args...)

#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...)

#ifdef CONFIG_BTRFS_ASSERT

#define btrfs_assertfail(expr, file, line)

#define ASSERT(expr)
#else
#define ASSERT
#endif

__printf(5, 6)
__cold
void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
		     unsigned int line, int error, const char *fmt, ...);

const char * __attribute_const__ btrfs_decode_error(int error);

#define btrfs_handle_fs_error(fs_info, error, fmt, args...)

__printf(5, 6)
__cold
void __btrfs_panic(const struct btrfs_fs_info *fs_info, const char *function,
		   unsigned int line, int error, const char *fmt, ...);
/*
 * If BTRFS_MOUNT_PANIC_ON_FATAL_ERROR is in mount_opt, __btrfs_panic
 * will panic().  Otherwise we BUG() here.
 */
#define btrfs_panic(fs_info, error, fmt, args...)

#if BITS_PER_LONG == 32
#define BTRFS_32BIT_MAX_FILE_SIZE
/*
 * The warning threshold is 5/8th of the MAX_LFS_FILESIZE that limits the logical
 * addresses of extents.
 *
 * For 4K page size it's about 10T, for 64K it's 160T.
 */
#define BTRFS_32BIT_EARLY_WARN_THRESHOLD
void btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info);
void btrfs_err_32bit_limit(struct btrfs_fs_info *fs_info);
#endif

#endif