From 3fc959eb069b4707f932cd4556c2df2ea91e6a20 Mon Sep 17 00:00:00 2001 From: Alex Markuze Date: Tue, 18 Mar 2025 15:50:01 +0000 Subject: [PATCH] fixups --- include/linux/ceph/ceph_debug.h | 9 ++++----- include/linux/ceph/ceph_san_logger.h | 7 ++++--- net/ceph/ceph_san_logger.c | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index 59c35957e0238..2d6509bbdca9f 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -22,8 +22,7 @@ pr_debug("%.*s %12.12s:%-4d:" fmt, \ 8 - (int)sizeof(KBUILD_MODNAME), " ", \ kbasename(__FILE__), __LINE__, ##__VA_ARGS__); \ - CEPH_SAN_LOG("%12.12s:%-4d : " fmt, \ - kbasename(__FILE__), __LINE__, ##__VA_ARGS__); \ + CEPH_SAN_LOG(fmt, ##__VA_ARGS__); \ } while (0) # define doutc(client, fmt, ...) \ do { \ @@ -32,8 +31,8 @@ kbasename(__FILE__), __LINE__, \ &client->fsid, client->monc.auth->global_id, \ ##__VA_ARGS__); \ - CEPH_SAN_LOG("%12.12s:%-4d:" fmt, \ - kbasename(__FILE__), __LINE__, ##__VA_ARGS__); \ + CEPH_SAN_LOG("[%pU:%llu] " fmt, &client->fsid, \ + client->monc.auth->global_id, ##__VA_ARGS__); \ } while (0) # else /* faux printk call just to see any compiler warnings. */ @@ -53,7 +52,7 @@ */ # define dout(fmt, ...) CEPH_SAN_LOG(fmt, ##__VA_ARGS__) # define doutc(client, fmt, ...) \ - CEPH_SAN_LOG(" [%pU %llu] %s: " fmt, &client->fsid, \ + CEPH_SAN_LOG(" [%pU:%llu] %s: " fmt, &client->fsid, \ client->monc.auth->global_id, __func__, ##__VA_ARGS__) #endif diff --git a/include/linux/ceph/ceph_san_logger.h b/include/linux/ceph/ceph_san_logger.h index e8614e46a51ae..b4c2cec7cd5b7 100644 --- a/include/linux/ceph/ceph_san_logger.h +++ b/include/linux/ceph/ceph_san_logger.h @@ -18,7 +18,8 @@ struct ceph_san_log_entry { unsigned int line; /* Line number */ unsigned int len; /* Length of the message */ const char *file; /* Source file */ - char buffer[0]; /* Flexible array for inline buffer */ + const char *func; /* Source function */ + char *buffer; /* Flexible array for inline buffer */ }; /* TLS context structure */ @@ -58,14 +59,14 @@ int ceph_san_logger_init(void); void ceph_san_logger_cleanup(void); /* Log a message */ -void ceph_san_log(const char *file, unsigned int line, const char *fmt, ...); +void ceph_san_log(const char *file, const char *func, unsigned int line, const char *fmt, ...); /* Get current TLS context, creating if necessary */ struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void); /* Helper macro for logging */ #define CEPH_SAN_LOG(fmt, ...) \ - ceph_san_log(__FILE__, __LINE__, fmt, ##__VA_ARGS__) + ceph_san_log(kbasename(__FILE__), __func__, __LINE__, fmt, ##__VA_ARGS__) /* Global logger instance */ extern struct ceph_san_logger g_logger; diff --git a/net/ceph/ceph_san_logger.c b/net/ceph/ceph_san_logger.c index 4e4461fe655d1..f423bc6d691c7 100644 --- a/net/ceph/ceph_san_logger.c +++ b/net/ceph/ceph_san_logger.c @@ -47,6 +47,7 @@ static void ceph_san_tls_release(void *ptr) return; /* Add context to log batch */ + ctx->task = NULL; ceph_san_batch_put(&g_logger.log_batch, ctx); /* If log_batch has too many full magazines, move one to alloc_batch */ @@ -100,7 +101,8 @@ struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void) /* Set up TLS */ current->tls.state = ctx; current->tls.release = ceph_san_tls_release; - + task_state_to_char(current); + ctx->task = current; return ctx; } EXPORT_SYMBOL(ceph_san_get_tls_ctx); @@ -113,7 +115,7 @@ EXPORT_SYMBOL(ceph_san_get_tls_ctx); * * Logs a message to the current TLS context's log buffer */ -void ceph_san_log(const char *file, unsigned int line, const char *fmt, ...) +void ceph_san_log(const char *file, const char *func, unsigned int line, const char *fmt, ...) { /* Format the message into local buffer first */ char buf[256]; @@ -158,6 +160,8 @@ void ceph_san_log(const char *file, unsigned int line, const char *fmt, ...) entry->ts = jiffies; entry->line = line; entry->file = file; + entry->func = func; + entry->buffer = (char *)(entry + 1); entry->len = cephsan_pagefrag_get_alloc_size(alloc); spin_unlock(&ctx->pf.lock); -- 2.39.5