debug.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  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. */
  8. #ifndef _LINUX_SUNRPC_DEBUG_H_
  9. #define _LINUX_SUNRPC_DEBUG_H_
  10. #include <uapi/linux/sunrpc/debug.h>
  11. /*
  12. * Debugging macros etc
  13. */
  14. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  15. extern unsigned int rpc_debug;
  16. extern unsigned int nfs_debug;
  17. extern unsigned int nfsd_debug;
  18. extern unsigned int nlm_debug;
  19. #endif
  20. #define dprintk(fmt, ...) \
  21. dfprintk(FACILITY, fmt, ##__VA_ARGS__)
  22. #define dprintk_cont(fmt, ...) \
  23. dfprintk_cont(FACILITY, fmt, ##__VA_ARGS__)
  24. #define dprintk_rcu(fmt, ...) \
  25. dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__)
  26. #define dprintk_rcu_cont(fmt, ...) \
  27. dfprintk_rcu_cont(FACILITY, fmt, ##__VA_ARGS__)
  28. #undef ifdebug
  29. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  30. # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
  31. # define dfprintk(fac, fmt, ...) \
  32. do { \
  33. ifdebug(fac) \
  34. printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
  35. } while (0)
  36. # define dfprintk_cont(fac, fmt, ...) \
  37. do { \
  38. ifdebug(fac) \
  39. printk(KERN_CONT fmt, ##__VA_ARGS__); \
  40. } while (0)
  41. # define dfprintk_rcu(fac, fmt, ...) \
  42. do { \
  43. ifdebug(fac) { \
  44. rcu_read_lock(); \
  45. printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
  46. rcu_read_unlock(); \
  47. } \
  48. } while (0)
  49. # define dfprintk_rcu_cont(fac, fmt, ...) \
  50. do { \
  51. ifdebug(fac) { \
  52. rcu_read_lock(); \
  53. printk(KERN_CONT fmt, ##__VA_ARGS__); \
  54. rcu_read_unlock(); \
  55. } \
  56. } while (0)
  57. # define RPC_IFDEBUG(x) x
  58. #else
  59. # define ifdebug(fac) if (0)
  60. # define dfprintk(fac, fmt, ...) do {} while (0)
  61. # define dfprintk_cont(fac, fmt, ...) do {} while (0)
  62. # define dfprintk_rcu(fac, fmt, ...) do {} while (0)
  63. # define RPC_IFDEBUG(x)
  64. #endif
  65. /*
  66. * Sysctl interface for RPC debugging
  67. */
  68. struct rpc_clnt;
  69. struct rpc_xprt;
  70. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  71. void rpc_register_sysctl(void);
  72. void rpc_unregister_sysctl(void);
  73. void sunrpc_debugfs_init(void);
  74. void sunrpc_debugfs_exit(void);
  75. void rpc_clnt_debugfs_register(struct rpc_clnt *);
  76. void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
  77. void rpc_xprt_debugfs_register(struct rpc_xprt *);
  78. void rpc_xprt_debugfs_unregister(struct rpc_xprt *);
  79. #else
  80. static inline void
  81. sunrpc_debugfs_init(void)
  82. {
  83. return;
  84. }
  85. static inline void
  86. sunrpc_debugfs_exit(void)
  87. {
  88. return;
  89. }
  90. static inline void
  91. rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
  92. {
  93. return;
  94. }
  95. static inline void
  96. rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
  97. {
  98. return;
  99. }
  100. static inline void
  101. rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
  102. {
  103. return;
  104. }
  105. static inline void
  106. rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt)
  107. {
  108. return;
  109. }
  110. #endif
  111. #endif /* _LINUX_SUNRPC_DEBUG_H_ */