1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _FS_CEPH_DEBUG_H 3 #define _FS_CEPH_DEBUG_H 4 5 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 6 7 #include <linux/string.h> 8 9 #ifdef CONFIG_CEPH_LIB_PRETTYDEBUG 10 11 /* 12 * wrap pr_debug to include a filename:lineno prefix on each line. 13 * this incurs some overhead (kernel size and execution time) due to 14 * the extra function call at each call site. 15 */ 16 17 # if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 18 # define dout(fmt, ...) \ 19 pr_debug("%.*s %12.12s:%-4d : " fmt, \ 20 8 - (int)sizeof(KBUILD_MODNAME), " ", \ 21 kbasename(__FILE__), __LINE__, ##__VA_ARGS__) 22 # define doutc(client, fmt, ...) \ 23 pr_debug("%.*s %12.12s:%-4d : [%pU %llu] " fmt, \ 24 8 - (int)sizeof(KBUILD_MODNAME), " ", \ 25 kbasename(__FILE__), __LINE__, \ 26 &client->fsid, client->monc.auth->global_id, \ 27 ##__VA_ARGS__) 28 # else 29 /* faux printk call just to see any compiler warnings. */ 30 # define dout(fmt, ...) do { \ 31 if (0) \ 32 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 33 } while (0) 34 # define doutc(client, fmt, ...) do { \ 35 if (0) \ 36 printk(KERN_DEBUG "[%pU %llu] " fmt, \ 37 &client->fsid, \ 38 client->monc.auth->global_id, \ 39 ##__VA_ARGS__); \ 40 } while (0) 41 # endif 42 43 #else 44 45 /* 46 * or, just wrap pr_debug 47 */ 48 # define dout(fmt, ...) pr_debug(" " fmt, ##__VA_ARGS__) 49 # define doutc(client, fmt, ...) \ 50 pr_debug(" [%pU %llu] %s: " fmt, &client->fsid, \ 51 client->monc.auth->global_id, __func__, ##__VA_ARGS__) 52 53 #endif 54 55 #define pr_notice_client(client, fmt, ...) \ 56 pr_notice("[%pU %llu]: " fmt, &client->fsid, \ 57 client->monc.auth->global_id, ##__VA_ARGS__) 58 #define pr_info_client(client, fmt, ...) \ 59 pr_info("[%pU %llu]: " fmt, &client->fsid, \ 60 client->monc.auth->global_id, ##__VA_ARGS__) 61 #define pr_warn_client(client, fmt, ...) \ 62 pr_warn("[%pU %llu]: " fmt, &client->fsid, \ 63 client->monc.auth->global_id, ##__VA_ARGS__) 64 #define pr_warn_once_client(client, fmt, ...) \ 65 pr_warn_once("[%pU %llu]: " fmt, &client->fsid, \ 66 client->monc.auth->global_id, ##__VA_ARGS__) 67 #define pr_err_client(client, fmt, ...) \ 68 pr_err("[%pU %llu]: " fmt, &client->fsid, \ 69 client->monc.auth->global_id, ##__VA_ARGS__) 70 #define pr_warn_ratelimited_client(client, fmt, ...) \ 71 pr_warn_ratelimited("[%pU %llu]: " fmt, &client->fsid, \ 72 client->monc.auth->global_id, ##__VA_ARGS__) 73 #define pr_err_ratelimited_client(client, fmt, ...) \ 74 pr_err_ratelimited("[%pU %llu]: " fmt, &client->fsid, \ 75 client->monc.auth->global_id, ##__VA_ARGS__) 76 77 #endif 78