]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
sizeof fixup
authorAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 11:18:51 +0000 (11:18 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Mon, 7 Apr 2025 11:25:10 +0000 (11:25 +0000)
fs/ceph/addr.c
include/linux/ceph/ceph_debug.h
include/linux/ceph/ceph_san_logger.h
net/ceph/ceph_san_logger.c
net/ceph/osdmap.c

index 85936f6d2bf705d6585535462d94fceb57786273..ced3420f7a2b6413f93f65fdbd8d57b6a94f2480 100644 (file)
@@ -2044,11 +2044,12 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
        if (*p)
                goto out;
 
-       if (pool_ns)
+       if (pool_ns) {
                doutc(cl, "pool %lld ns %.*s no perm cached\n", pool,
-                     (int)pool_ns->len, pool_ns->str);
-       else
+                     (int)pool_ns->len, "FIXME");
+       } else {
                doutc(cl, "pool %lld no perm cached\n", pool);
+       }
 
        down_write(&mdsc->pool_perm_rwsem);
        p = &mdsc->pool_perm_tree.rb_node;
@@ -2172,11 +2173,12 @@ out_unlock:
 out:
        if (!err)
                err = have;
-       if (pool_ns)
+       if (pool_ns) {
                doutc(cl, "pool %lld ns %.*s result = %d\n", pool,
-                     (int)pool_ns->len, pool_ns->str, err);
-       else
+                     (int)pool_ns->len, "FIXME", err);
+       } else {
                doutc(cl, "pool %lld result = %d\n", pool, err);
+       }
        return err;
 }
 
index 2d6509bbdca9f142a8dd0dbb8dd9dcf5c3e2225c..b39707794d767b171f175d5c19bf20b35f2e24ea 100644 (file)
@@ -52,8 +52,8 @@
  */
 # define dout(fmt, ...)        CEPH_SAN_LOG(fmt, ##__VA_ARGS__)
 # define doutc(client, fmt, ...)                                       \
-       CEPH_SAN_LOG(" [%pU:%llu] %s: " fmt, &client->fsid,                     \
-                client->monc.auth->global_id, __func__, ##__VA_ARGS__)
+       CEPH_SAN_LOG("[%pU:%llu] " fmt, &client->fsid,                  \
+                client->monc.auth->global_id, ##__VA_ARGS__);
 
 #endif
 
index dca0b57f7f48177a1506aef92e7e4b0a29845d61..df86f6e039b3a426a389acbffc78271a880b4278 100644 (file)
@@ -19,6 +19,7 @@ struct ceph_san_source_info {
     const char *file;
     const char *func;
     unsigned int line;
+    const char *fmt;         /* Format string */
 };
 
 /* Log entry structure */
@@ -71,13 +72,13 @@ int ceph_san_logger_init(void);
 void ceph_san_logger_cleanup(void);
 
 /* Get or create source ID */
-u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line);
+u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line, const char *fmt);
 
 /* Get source information for ID */
 const struct ceph_san_source_info *ceph_san_get_source_info(u32 id);
 
 /* Log a message */
-void ceph_san_log(u32 source_id, const char *fmt, ...);
+void ceph_san_log(u32 source_id, ...);
 
 /* Get current TLS context, creating if necessary */
 struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void);
@@ -86,10 +87,12 @@ struct ceph_san_tls_ctx *ceph_san_get_tls_ctx(void);
 #define CEPH_SAN_LOG(fmt, ...) \
     do { \
         static u32 __source_id = 0; \
+        static size_t __size = 0; \
         if (__source_id == 0) { \
-            __source_id = ceph_san_get_source_id(kbasename(__FILE__), __func__, __LINE__); \
+            __source_id = ceph_san_get_source_id(kbasename(__FILE__), __func__, __LINE__, fmt); \
+            __size = ceph_san_cnt(__VA_ARGS__); \
         } \
-        ceph_san_log(__source_id, fmt, ##__VA_ARGS__); \
+        ceph_san_log(__source_id, ##__VA_ARGS__); \
     } while (0)
 
 /* Global logger instance */
index e2c8ec3d5b903916cf79b695446253eaa1385cc3..ac243a70c08ee8ae1bfbf65fc0d1b40f8b462c37 100644 (file)
@@ -114,10 +114,11 @@ EXPORT_SYMBOL(ceph_san_get_tls_ctx);
  * @file: Source file name
  * @func: Function name
  * @line: Line number
+ * @fmt: Format string
  *
  * Returns a unique ID for this source location
  */
-u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line)
+u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line, const char *fmt)
 {
     u32 id = atomic_inc_return(&g_logger.next_source_id);
 
@@ -131,6 +132,7 @@ u32 ceph_san_get_source_id(const char *file, const char *func, unsigned int line
     g_logger.source_map[id].file = file;
     g_logger.source_map[id].func = func;
     g_logger.source_map[id].line = line;
+    g_logger.source_map[id].fmt = fmt;
 
     return id;
 }
@@ -153,11 +155,11 @@ EXPORT_SYMBOL(ceph_san_get_source_info);
 /**
  * ceph_san_log - Log a message
  * @source_id: Source ID for this location
- * @fmt: Format string
  *
  * 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, const char *fmt, ...)
+void ceph_san_log(u32 source_id, ...)
 {
     /* Format the message into local buffer first */
     char buf[256];
@@ -166,6 +168,7 @@ void ceph_san_log(u32 source_id, const char *fmt, ...)
     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) {
@@ -173,8 +176,15 @@ void ceph_san_log(u32 source_id, const char *fmt, ...)
         return;
     }
 
-    va_start(args, fmt);
-    len = vsnprintf(buf, sizeof(buf), fmt, args);
+    /* 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;
+    }
+
+    va_start(args, source_id);
+    len = vsnprintf(buf, sizeof(buf), source_info->fmt, args);
     va_end(args);
 
     needed_size = sizeof(*entry) + len + 1;
index 2950988738614fa90a6be8b3169a277fa963bcb4..f089d214fff691c26b3760efd1eb1d297bda6002 100644 (file)
@@ -2401,7 +2401,7 @@ void __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
                raw_pgid->pool = oloc->pool;
                raw_pgid->seed = ceph_str_hash(pi->object_hash, oid->name,
                                             oid->name_len);
-               dout("%s %s -> raw_pgid %llu.%x\n", __func__, oid->name,
+               dout("%s -> raw_pgid %llu.%x\n", oid->name,
                     raw_pgid->pool, raw_pgid->seed);
        } else {
                char stack_buf[256];
@@ -2418,8 +2418,8 @@ void __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
                raw_pgid->seed = ceph_str_hash(pi->object_hash, buf, total);
                if (buf != stack_buf)
                        kfree(buf);
-               dout("%s %s ns %.*s -> raw_pgid %llu.%x\n", __func__,
-                    oid->name, nsl, oloc->pool_ns->str,
+               dout("%s ns %.*s -> raw_pgid %llu.%x\n",
+                    oid->name, nsl, "FIXME -- POOL NS name",//oloc->pool_ns->str,
                     raw_pgid->pool, raw_pgid->seed);
        }
 }