Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * linux/include/linux/sunrpc/debug.h
4 *
5 * Debugging support for sunrpc module
6 *
7 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
8 */
9#ifndef _LINUX_SUNRPC_DEBUG_H_
10#define _LINUX_SUNRPC_DEBUG_H_
11
12#include <uapi/linux/sunrpc/debug.h>
13
14/*
15 * Debugging macros etc
16 */
17extern unsigned int rpc_debug;
18extern unsigned int nfs_debug;
19extern unsigned int nfsd_debug;
20extern unsigned int nlm_debug;
21
22#define dprintk(fmt, ...) \
23 dfprintk(FACILITY, fmt, ##__VA_ARGS__)
24#define dprintk_rcu(fmt, ...) \
25 dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__)
26
27#undef ifdebug
28#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
29# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
30
31# if IS_ENABLED(CONFIG_SUNRPC_DEBUG_TRACE)
32# define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__)
33# else
34# define __sunrpc_printk(fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__)
35# endif
36
37# define dfprintk(fac, fmt, ...) \
38do { \
39 ifdebug(fac) \
40 __sunrpc_printk(fmt, ##__VA_ARGS__); \
41 else \
42 no_printk(fmt, ##__VA_ARGS__); \
43} while (0)
44
45# define dfprintk_rcu(fac, fmt, ...) \
46do { \
47 ifdebug(fac) { \
48 rcu_read_lock(); \
49 __sunrpc_printk(fmt, ##__VA_ARGS__); \
50 rcu_read_unlock(); \
51 } else { \
52 no_printk(fmt, ##__VA_ARGS__); \
53 } \
54} while (0)
55
56#else
57# define ifdebug(fac) if (0)
58# define dfprintk(fac, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
59# define dfprintk_rcu(fac, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
60#endif
61
62/*
63 * Sysctl interface for RPC debugging
64 */
65
66struct rpc_clnt;
67struct rpc_xprt;
68
69#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
70void rpc_register_sysctl(void);
71void rpc_unregister_sysctl(void);
72void sunrpc_debugfs_init(void);
73void sunrpc_debugfs_exit(void);
74void rpc_clnt_debugfs_register(struct rpc_clnt *);
75void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
76void rpc_xprt_debugfs_register(struct rpc_xprt *);
77void rpc_xprt_debugfs_unregister(struct rpc_xprt *);
78#else
79static inline void
80sunrpc_debugfs_init(void)
81{
82 return;
83}
84
85static inline void
86sunrpc_debugfs_exit(void)
87{
88 return;
89}
90
91static inline void
92rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
93{
94 return;
95}
96
97static inline void
98rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
99{
100 return;
101}
102
103static inline void
104rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
105{
106 return;
107}
108
109static inline void
110rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt)
111{
112 return;
113}
114#endif
115
116#endif /* _LINUX_SUNRPC_DEBUG_H_ */