[PATCH v2 08/15] ceph: add bout and boutc wrappers for BLOG
Alex Markuze <[email protected]> Mon, 6 Jul 2026 14:38:36 +0000
| Newsgroups | org.kernel.vger.ceph-devel |
|---|---|
| Message-ID | <[email protected]> |
Add bout()/boutc() macros to ceph_debug.h as drop-in replacements for dout()/doutc(). When BLOG is enabled they serialize to binary; when disabled they compile to nothing. Signed-off-by: Alex Markuze <[email protected]> --- include/linux/ceph/ceph_debug.h | 44 ++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index 5f904591fa5f..621f9190e6e7 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -8,25 +8,18 @@ #ifdef CONFIG_CEPH_LIB_PRETTYDEBUG -/* - * wrap pr_debug to include a filename:lineno prefix on each line. - * this incurs some overhead (kernel size and execution time) due to - * the extra function call at each call site. - */ - # if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) # define dout(fmt, ...) \ pr_debug("%.*s %12.12s:%-4d : " fmt, \ 8 - (int)sizeof(KBUILD_MODNAME), " ", \ kbasename(__FILE__), __LINE__, ##__VA_ARGS__) # define doutc(client, fmt, ...) \ - pr_debug("%.*s %12.12s:%-4d : [%pU %llu] " fmt, \ + pr_debug("%.*s %12.12s:%-4d : [%pU %llu] " fmt, \ 8 - (int)sizeof(KBUILD_MODNAME), " ", \ kbasename(__FILE__), __LINE__, \ &client->fsid, client->monc.auth->global_id, \ ##__VA_ARGS__) # else -/* faux printk call just to see any compiler warnings. */ # define dout(fmt, ...) \ no_printk(KERN_DEBUG fmt, ##__VA_ARGS__) # define doutc(client, fmt, ...) \ @@ -38,16 +31,43 @@ #else -/* - * or, just wrap pr_debug - */ # define dout(fmt, ...) pr_debug(" " fmt, ##__VA_ARGS__) # define doutc(client, fmt, ...) \ - pr_debug(" [%pU %llu] %s: " fmt, &client->fsid, \ + pr_debug(" [%pU %llu] %s: " fmt, &client->fsid, \ client->monc.auth->global_id, __func__, ##__VA_ARGS__) #endif +/* + * bout / boutc -- binary-logging variants. + * + * When Ceph BLOG tracing has been explicitly enabled and a BLOG context + * has been cached in current->journal_info (via ceph_blog_enter()), + * these route through the BLOG serialization path. Otherwise they fall + * back to the traditional text-based dout/doutc macros so that existing + * debug semantics remain unchanged. + */ +#if IS_ENABLED(CONFIG_CEPH_FS) +# include <linux/ceph/ceph_blog.h> +# define bout(fmt, ...) \ + do { \ + if (ceph_blog_get_cached_ctx()) \ + CEPH_BLOG_LOG(fmt, ##__VA_ARGS__); \ + else \ + dout(fmt, ##__VA_ARGS__); \ + } while (0) +# define boutc(client, fmt, ...) \ + do { \ + if (ceph_blog_get_cached_ctx()) \ + CEPH_BLOG_LOG_CLIENT(client, fmt, ##__VA_ARGS__); \ + else \ + doutc(client, fmt, ##__VA_ARGS__); \ + } while (0) +#else +# define bout(fmt, ...) dout(fmt, ##__VA_ARGS__) +# define boutc(client, fmt, ...) doutc(client, fmt, ##__VA_ARGS__) +#endif + #define pr_notice_client(client, fmt, ...) \ pr_notice("[%pU %llu]: " fmt, &client->fsid, \ client->monc.auth->global_id, ##__VA_ARGS__) -- 2.34.1