diff options
-rw-r--r-- | fs/btrfs/Kconfig | 9 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig index 2b3b83296977..398cbd517be2 100644 --- a/fs/btrfs/Kconfig +++ b/fs/btrfs/Kconfig | |||
@@ -72,3 +72,12 @@ config BTRFS_DEBUG | |||
72 | performance, or export extra information via sysfs. | 72 | performance, or export extra information via sysfs. |
73 | 73 | ||
74 | If unsure, say N. | 74 | If unsure, say N. |
75 | |||
76 | config BTRFS_ASSERT | ||
77 | bool "Btrfs assert support" | ||
78 | depends on BTRFS_FS | ||
79 | help | ||
80 | Enable run-time assertion checking. This will result in panics if | ||
81 | any of the assertions trip. This is meant for btrfs developers only. | ||
82 | |||
83 | If unsure, say N. | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c90be01cbe67..1f3fd584e5f4 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -3814,6 +3814,22 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) | |||
3814 | #define btrfs_debug(fs_info, fmt, args...) \ | 3814 | #define btrfs_debug(fs_info, fmt, args...) \ |
3815 | btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) | 3815 | btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) |
3816 | 3816 | ||
3817 | #ifdef CONFIG_BTRFS_ASSERT | ||
3818 | |||
3819 | static inline void assfail(char *expr, char *file, int line) | ||
3820 | { | ||
3821 | printk(KERN_ERR "BTRFS assertion failed: %s, file: %s, line: %d", | ||
3822 | expr, file, line); | ||
3823 | BUG(); | ||
3824 | } | ||
3825 | |||
3826 | #define ASSERT(expr) \ | ||
3827 | (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
3828 | #else | ||
3829 | #define ASSERT(expr) ((void)0) | ||
3830 | #endif | ||
3831 | |||
3832 | #define btrfs_assert() | ||
3817 | __printf(5, 6) | 3833 | __printf(5, 6) |
3818 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | 3834 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, |
3819 | unsigned int line, int errno, const char *fmt, ...); | 3835 | unsigned int line, int errno, const char *fmt, ...); |