]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
serializing input parameters
authorAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 12:00:57 +0000 (12:00 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 12:00:57 +0000 (12:00 +0000)
include/linux/ceph/ceph_san_logger.h
net/ceph/ceph_san_logger.c

index 0b377119abb9f8ba14d2b99c91751d67b67df4f9..b007c0cff4f2d9ac74415d16a5388786109a1ac5 100644 (file)
@@ -79,7 +79,7 @@ u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line
 const struct ceph_san_source_info *ceph_san_get_source_info(u32 id);
 
 /* Log a message */
-void ceph_san_log(u32 source_id, ...);
+void* ceph_san_log(u32 source_id, size_t size);
 
 /* Get current TLS context, creating if necessary */
 struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void);
@@ -89,11 +89,15 @@ struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void);
     do { \
         static u32 __source_id = 0; \
         static size_t __size = 0; \
+        void *__buffer = NULL; \
         if (unlikely(__source_id == 0)) { \
             __source_id = ceph_san_get_source_id(kbasename(__FILE__), __func__, __LINE__, fmt); \
             __size = ceph_san_cnt(__VA_ARGS__); \
         } \
-        ceph_san_log(__source_id, ##__VA_ARGS__); \
+        __buffer = ceph_san_log(__source_id, __size); \
+        if (__buffer) { \
+            ceph_san_ser(__buffer, ##__VA_ARGS__); \
+        } \
     } while (0)
 
 /* Global logger instance */
index ac243a70c08ee8ae1bfbf65fc0d1b40f8b462c37..46127229cc3244f081f34cd1589fe1abb6d27eda 100644 (file)
@@ -159,35 +159,19 @@ EXPORT_SYMBOL(ceph_san_get_source_info);
  * Logs a message to the current TLS context's log buffer
  * Format string is retrieved from the source_map
  */
-void ceph_san_log(u32 source_id, ...)
+void* ceph_san_log(u32 source_id, size_t needed_size)
 {
     /* Format the message into local buffer first */
-    char buf[256];
     struct ceph_san_tls_ctx *ctx;
     struct ceph_san_log_entry *entry;
-    va_list args;
     u64 alloc;
-    int len, needed_size;
-    const struct ceph_san_source_info *source_info;
 
     ctx = ceph_san_get_tls_ctx();
     if (!ctx) {
         pr_err("Failed to get TLS context\n");
-        return;
-    }
-
-    /* Get format string from source info */
-    source_info = ceph_san_get_source_info(source_id);
-    if (!source_info || !source_info->fmt) {
-        pr_err("Invalid source ID or missing format string\n");
-        return;
+        return NULL;
     }
 
-    va_start(args, source_id);
-    len = vsnprintf(buf, sizeof(buf), source_info->fmt, args);
-    va_end(args);
-
-    needed_size = sizeof(*entry) + len + 1;
     /* Allocate entry from pagefrag - We need a spinlock here to protect access iterators */
     spin_lock_bh(&ctx->pf.lock);
     alloc = cephsan_pagefrag_alloc(&ctx->pf, needed_size);
@@ -233,9 +217,7 @@ void ceph_san_log(u32 source_id, ...)
     entry->len = cephsan_pagefrag_get_alloc_size(alloc);
     spin_unlock_bh(&ctx->pf.lock);
 
-    /* Copy to entry buffer */
-    memcpy(entry->buffer, buf, len + 1);
-    entry->buffer[len] = '\0';
+    return entry->buffer;
 }
 EXPORT_SYMBOL(ceph_san_log);