|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | +#ifndef LINUX_VFS_DEBUG_H |
| 3 | +#define LINUX_VFS_DEBUG_H 1 |
| 4 | + |
| 5 | +#include <linux/bug.h> |
| 6 | + |
| 7 | +struct inode; |
| 8 | + |
| 9 | +#ifdef CONFIG_DEBUG_VFS |
| 10 | +void dump_inode(struct inode *inode, const char *reason); |
| 11 | + |
| 12 | +#define VFS_BUG_ON(cond) BUG_ON(cond) |
| 13 | +#define VFS_WARN_ON(cond) (void)WARN_ON(cond) |
| 14 | +#define VFS_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond) |
| 15 | +#define VFS_WARN_ONCE(cond, format...) (void)WARN_ONCE(cond, format) |
| 16 | +#define VFS_WARN(cond, format...) (void)WARN(cond, format) |
| 17 | + |
| 18 | +#define VFS_BUG_ON_INODE(cond, inode) ({ \ |
| 19 | + if (unlikely(!!(cond))) { \ |
| 20 | + dump_inode(inode, "VFS_BUG_ON_INODE(" #cond")");\ |
| 21 | + BUG_ON(1); \ |
| 22 | + } \ |
| 23 | +}) |
| 24 | + |
| 25 | +#define VFS_WARN_ON_INODE(cond, inode) ({ \ |
| 26 | + int __ret_warn = !!(cond); \ |
| 27 | + \ |
| 28 | + if (unlikely(__ret_warn)) { \ |
| 29 | + dump_inode(inode, "VFS_WARN_ON_INODE(" #cond")");\ |
| 30 | + WARN_ON(1); \ |
| 31 | + } \ |
| 32 | + unlikely(__ret_warn); \ |
| 33 | +}) |
| 34 | +#else |
| 35 | +#define VFS_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) |
| 36 | +#define VFS_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) |
| 37 | +#define VFS_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) |
| 38 | +#define VFS_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) |
| 39 | +#define VFS_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond) |
| 40 | + |
| 41 | +#define VFS_BUG_ON_INODE(cond, inode) VFS_BUG_ON(cond) |
| 42 | +#define VFS_WARN_ON_INODE(cond, inode) BUILD_BUG_ON_INVALID(cond) |
| 43 | +#endif /* CONFIG_DEBUG_VFS */ |
| 44 | + |
| 45 | +#endif |
0 commit comments