blob: 83533970709437fc7a138571edf931f17ed38066 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/linux/sunrpc/debug.h
3 *
4 * Debugging support for sunrpc module
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#ifndef _LINUX_SUNRPC_DEBUG_H_
9#define _LINUX_SUNRPC_DEBUG_H_
10
David Howellse3dd9a52012-10-09 09:49:04 +010011#include <uapi/linux/sunrpc/debug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013/*
14 * Debugging macros etc
15 */
Jeff Laytonf895b252014-11-17 16:58:04 -050016#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070017extern unsigned int rpc_debug;
18extern unsigned int nfs_debug;
19extern unsigned int nfsd_debug;
20extern unsigned int nlm_debug;
21#endif
22
23#define dprintk(args...) dfprintk(FACILITY, ## args)
Trond Myklebust2446ab62012-03-01 17:00:56 -050024#define dprintk_rcu(args...) dfprintk_rcu(FACILITY, ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#undef ifdebug
Jeff Laytonf895b252014-11-17 16:58:04 -050027#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
Trond Myklebust2446ab62012-03-01 17:00:56 -050029
Chuck Leverdbb9c2a2012-02-15 16:35:08 -050030# define dfprintk(fac, args...) \
31 do { \
32 ifdebug(fac) \
33 printk(KERN_DEFAULT args); \
34 } while (0)
Trond Myklebust2446ab62012-03-01 17:00:56 -050035
36# define dfprintk_rcu(fac, args...) \
37 do { \
38 ifdebug(fac) { \
39 rcu_read_lock(); \
40 printk(KERN_DEFAULT args); \
41 rcu_read_unlock(); \
42 } \
43 } while (0)
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045# define RPC_IFDEBUG(x) x
46#else
47# define ifdebug(fac) if (0)
Chuck Leverb3b536a2012-03-20 19:20:53 -040048# define dfprintk(fac, args...) do {} while (0)
49# define dfprintk_rcu(fac, args...) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050# define RPC_IFDEBUG(x)
51#endif
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/*
54 * Sysctl interface for RPC debugging
55 */
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -050056
57struct rpc_clnt;
58
Jeff Laytonf895b252014-11-17 16:58:04 -050059#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060void rpc_register_sysctl(void);
61void rpc_unregister_sysctl(void);
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -050062int sunrpc_debugfs_init(void);
63void sunrpc_debugfs_exit(void);
64int rpc_clnt_debugfs_register(struct rpc_clnt *);
65void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
66#else
67static inline int
68sunrpc_debugfs_init(void)
69{
70 return 0;
71}
72
73static inline void
74sunrpc_debugfs_exit(void)
75{
76 return;
77}
78
79static inline int
80rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
81{
82 return 0;
83}
84
85static inline void
86rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
87{
88 return;
89}
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#endif
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif /* _LINUX_SUNRPC_DEBUG_H_ */