]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
cephsan: bug fixes
authorAlex Markuze <amarkuze@redhat.com>
Mon, 3 Mar 2025 16:51:54 +0000 (16:51 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Mon, 3 Mar 2025 16:51:54 +0000 (16:51 +0000)
include/linux/ceph/ceph_san.h
net/ceph/ceph_san.c

index 33aa9945dd1a86b773a85d6f936ee184731c0aad..e91e14efa3df017471d56c331143aaf45c3a83cc 100644 (file)
@@ -112,7 +112,7 @@ struct ceph_san_log_entry_tls {
     char *buf;
 };
 struct histogram {
-       u64 counters[16];
+       u64 counters[32];
 };
 
 struct ceph_san_percore_logger {
@@ -130,8 +130,9 @@ struct ceph_san_tls_logger {
 
 /* Bundled TLS context containing both logger and memory caches */
 struct tls_ceph_san_context {
-    struct ceph_san_tls_logger logger;
+       u64 sig;
     struct list_head list;  /* For global list of contexts */
+    struct ceph_san_tls_logger logger;
     /* We no longer use pagefrag for log entries */
 };
 
index e23e50045610cb61b6768e58fdb26a8b3782fd5f..77e7cc8aaf89050594409ade0b9f5535272f6ffc 100644 (file)
@@ -29,7 +29,7 @@ static inline void *cephsan_pagefrag_get_ptr(struct cephsan_pagefrag *pf, u64 va
  * have been moved to cephsan.h (under CONFIG_DEBUG_FS) to avoid duplication.
  */
 
-
+#define CEPH_SAN_SIG 0xDEADC0DE
 /* Release function for TLS storage */
 static void ceph_san_tls_release(void *ptr)
 {
@@ -37,6 +37,10 @@ static void ceph_san_tls_release(void *ptr)
     if (!context)
         return;
 
+    if (context->sig != CEPH_SAN_SIG)
+           pr_err("sig is wrong %p %llx != %llx", context, context->sig, CEPH_SAN_SIG);
+           return;
+
     /* Remove from global list with lock protection */
     spin_lock(&g_ceph_san_contexts_lock);
     list_del(&context->list);
@@ -78,14 +82,16 @@ static struct tls_ceph_san_context *get_cephsan_context(void) {
 
      /* Initialize list entry */
     INIT_LIST_HEAD(&context->list);
+    context->sig = CEPH_SAN_SIG;
+
+    current->tls.state = context;
+    current->tls.release = ceph_san_tls_release;
 
     /* Add to global list with lock protection */
     spin_lock(&g_ceph_san_contexts_lock);
     list_add(&context->list, &g_ceph_san_contexts);
     spin_unlock(&g_ceph_san_contexts_lock);
 
-    current->tls.state = context;
-    current->tls.release = ceph_san_tls_release;
     return context;
 }
 
@@ -119,7 +125,7 @@ void log_cephsan_tls(char *buf) {
         /* Allocate new buffer from appropriate cache */
         if (len <= LOG_BUF_SMALL) {
             new_buf = kmem_cache_alloc(ceph_san_log_128_cache, GFP_KERNEL);
-                       entry->ts = jiffies | 0x0;
+                       entry->ts = jiffies & ~0x1;
         } else {
             new_buf = kmem_cache_alloc(ceph_san_log_256_cache, GFP_KERNEL);
                        entry->ts = jiffies | 0x1;
@@ -160,7 +166,7 @@ static void log_cephsan_percore(char *buf) {
     buf_idx = cephsan_pagefrag_alloc(pf, len);
     if (buf_idx) {
         pc->head_idx = head_idx;
-        pc->histogram.counters[len >> 3]++;
+        pc->histogram.counters[(len >= 256) ? 31 : len >> 3]++;
         pc->logs[head_idx].len = len;
         pc->logs[head_idx].buf = cephsan_pagefrag_get_ptr(pf, buf_idx);
         memcpy(pc->logs[head_idx].buf, buf, len);
@@ -188,7 +194,7 @@ void cephsan_cleanup(void)
             pc->pages = NULL;
         }
     }
-
+#if 0
        /* Let the TLS contexts cleanup lazily */
     if (ceph_san_tls_logger_cache) {
         kmem_cache_destroy(ceph_san_tls_logger_cache);
@@ -204,6 +210,7 @@ void cephsan_cleanup(void)
         kmem_cache_destroy(ceph_san_log_256_cache);
         ceph_san_log_256_cache = NULL;
     }
+#endif
 }
 EXPORT_SYMBOL(cephsan_cleanup);