From: Alex Markuze Date: Mon, 7 Apr 2025 11:18:51 +0000 (+0000) Subject: sizeof fixup X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0ee3f8aa9fe9aaa54ee2e1afde72b1b538f9f6ae;p=ceph-client.git sizeof fixup --- diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 85936f6d2bf7..ced3420f7a2b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -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; } diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index 2d6509bbdca9..b39707794d76 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -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 diff --git a/include/linux/ceph/ceph_san_logger.h b/include/linux/ceph/ceph_san_logger.h index dca0b57f7f48..df86f6e039b3 100644 --- a/include/linux/ceph/ceph_san_logger.h +++ b/include/linux/ceph/ceph_san_logger.h @@ -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 */ diff --git a/net/ceph/ceph_san_logger.c b/net/ceph/ceph_san_logger.c index e2c8ec3d5b90..ac243a70c08e 100644 --- a/net/ceph/ceph_san_logger.c +++ b/net/ceph/ceph_san_logger.c @@ -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; diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 295098873861..f089d214fff6 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -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); } }