Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame^] | 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 | */ |
| 17 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
| 18 | extern unsigned int rpc_debug; |
| 19 | extern unsigned int nfs_debug; |
| 20 | extern unsigned int nfsd_debug; |
| 21 | extern unsigned int nlm_debug; |
| 22 | #endif |
| 23 | |
| 24 | #define dprintk(fmt, ...) \ |
| 25 | dfprintk(FACILITY, fmt, ##__VA_ARGS__) |
| 26 | #define dprintk_cont(fmt, ...) \ |
| 27 | dfprintk_cont(FACILITY, fmt, ##__VA_ARGS__) |
| 28 | #define dprintk_rcu(fmt, ...) \ |
| 29 | dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__) |
| 30 | #define dprintk_rcu_cont(fmt, ...) \ |
| 31 | dfprintk_rcu_cont(FACILITY, fmt, ##__VA_ARGS__) |
| 32 | |
| 33 | #undef ifdebug |
| 34 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
| 35 | # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) |
| 36 | |
| 37 | # define dfprintk(fac, fmt, ...) \ |
| 38 | do { \ |
| 39 | ifdebug(fac) \ |
| 40 | printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ |
| 41 | } while (0) |
| 42 | |
| 43 | # define dfprintk_cont(fac, fmt, ...) \ |
| 44 | do { \ |
| 45 | ifdebug(fac) \ |
| 46 | printk(KERN_CONT fmt, ##__VA_ARGS__); \ |
| 47 | } while (0) |
| 48 | |
| 49 | # define dfprintk_rcu(fac, fmt, ...) \ |
| 50 | do { \ |
| 51 | ifdebug(fac) { \ |
| 52 | rcu_read_lock(); \ |
| 53 | printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ |
| 54 | rcu_read_unlock(); \ |
| 55 | } \ |
| 56 | } while (0) |
| 57 | |
| 58 | # define dfprintk_rcu_cont(fac, fmt, ...) \ |
| 59 | do { \ |
| 60 | ifdebug(fac) { \ |
| 61 | rcu_read_lock(); \ |
| 62 | printk(KERN_CONT fmt, ##__VA_ARGS__); \ |
| 63 | rcu_read_unlock(); \ |
| 64 | } \ |
| 65 | } while (0) |
| 66 | |
| 67 | # define RPC_IFDEBUG(x) x |
| 68 | #else |
| 69 | # define ifdebug(fac) if (0) |
| 70 | # define dfprintk(fac, fmt, ...) do {} while (0) |
| 71 | # define dfprintk_cont(fac, fmt, ...) do {} while (0) |
| 72 | # define dfprintk_rcu(fac, fmt, ...) do {} while (0) |
| 73 | # define RPC_IFDEBUG(x) |
| 74 | #endif |
| 75 | |
| 76 | /* |
| 77 | * Sysctl interface for RPC debugging |
| 78 | */ |
| 79 | |
| 80 | struct rpc_clnt; |
| 81 | struct rpc_xprt; |
| 82 | |
| 83 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
| 84 | void rpc_register_sysctl(void); |
| 85 | void rpc_unregister_sysctl(void); |
| 86 | void sunrpc_debugfs_init(void); |
| 87 | void sunrpc_debugfs_exit(void); |
| 88 | void rpc_clnt_debugfs_register(struct rpc_clnt *); |
| 89 | void rpc_clnt_debugfs_unregister(struct rpc_clnt *); |
| 90 | void rpc_xprt_debugfs_register(struct rpc_xprt *); |
| 91 | void rpc_xprt_debugfs_unregister(struct rpc_xprt *); |
| 92 | #else |
| 93 | static inline void |
| 94 | sunrpc_debugfs_init(void) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | static inline void |
| 100 | sunrpc_debugfs_exit(void) |
| 101 | { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | static inline void |
| 106 | rpc_clnt_debugfs_register(struct rpc_clnt *clnt) |
| 107 | { |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | static inline void |
| 112 | rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt) |
| 113 | { |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | static inline void |
| 118 | rpc_xprt_debugfs_register(struct rpc_xprt *xprt) |
| 119 | { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | static inline void |
| 124 | rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt) |
| 125 | { |
| 126 | return; |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | #endif /* _LINUX_SUNRPC_DEBUG_H_ */ |