]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
minor fixups
authorAlex Markuze <amarkuze@redhat.com>
Sun, 16 Mar 2025 18:38:49 +0000 (18:38 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Sun, 16 Mar 2025 18:38:49 +0000 (18:38 +0000)
net/ceph/ceph_san_batch.c
net/ceph/ceph_san_logger.c

index 4b3c37850434c6b2aa06a88e0d7a6a97b30404ce..08d33bc7990068758665a9839a6f1d0e2ef6b121 100644 (file)
@@ -185,7 +185,6 @@ void *ceph_san_batch_get(struct ceph_san_batch *batch)
             spin_unlock(&batch->full_lock);
         }
     }
-
     return element;
 }
 EXPORT_SYMBOL(ceph_san_batch_get);
@@ -211,7 +210,7 @@ void ceph_san_batch_put(struct ceph_san_batch *batch, void *element)
     /* If current magazine is full, move it to full pool */
     if (likely(cpu_mag->mag && cpu_mag->mag->count >= CEPH_SAN_MAGAZINE_SIZE)) {
         spin_lock(&batch->full_lock);
-        list_add(&cpu_mag->mag->list, &batch->full_magazines);
+        list_add_tail(&cpu_mag->mag->list, &batch->full_magazines);
         batch->nr_full++;
         spin_unlock(&batch->full_lock);
         cpu_mag->mag = NULL;
index 95582fbada8508d4cc151f762791a4de58284a06..7726a539ce0aad8d11a467b33d7f7dc5452bdbad 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/string.h>
 #include <linux/ceph/ceph_san_logger.h>
 
+#define CEPH_SAN_LOG_BATCH_MAX_FULL 128
 /* Global logger instance */
 static struct ceph_san_logger g_logger;
 
@@ -14,12 +15,15 @@ static void *alloc_tls_ctx(void)
 {
     struct ceph_san_tls_ctx *ctx;
     ctx = kmem_cache_alloc(g_logger.alloc_batch.magazine_cache, GFP_KERNEL);
-    if (!ctx)
+    if (!ctx) {
+        pr_err("Failed to allocate TLS context from magazine cache\n");
         return NULL;
+    }
 
     /* Initialize pagefrag */
     memset(&ctx->pf, 0, sizeof(ctx->pf));
     if (cephsan_pagefrag_init(&ctx->pf)) {
+        pr_err("Failed to initialize pagefrag for TLS context\n");
         kmem_cache_free(g_logger.alloc_batch.magazine_cache, ctx);
         return NULL;
     }
@@ -44,6 +48,25 @@ static void ceph_san_tls_release(void *ptr)
     /* Add context to log batch */
     ceph_san_batch_put(&g_logger.log_batch, ctx);
 
+    /* If log_batch has too many full magazines, move one to alloc_batch */
+    if (g_logger.log_batch.nr_full > CEPH_SAN_LOG_BATCH_MAX_FULL) {
+        struct ceph_san_magazine *mag;
+        spin_lock(&g_logger.log_batch.full_lock);
+        if (!list_empty(&g_logger.log_batch.full_magazines)) {
+            mag = list_first_entry(&g_logger.log_batch.full_magazines,
+                                 struct ceph_san_magazine, list);
+            list_del(&mag->list);
+            g_logger.log_batch.nr_full--;
+            spin_unlock(&g_logger.log_batch.full_lock);
+
+            spin_lock(&g_logger.alloc_batch.full_lock);
+            list_add(&mag->list, &g_logger.alloc_batch.full_magazines);
+            g_logger.alloc_batch.nr_full++;
+            spin_unlock(&g_logger.alloc_batch.full_lock);
+        } else {
+            spin_unlock(&g_logger.log_batch.full_lock);
+        }
+    }
     current->tls.state = NULL;
 }
 
@@ -166,8 +189,7 @@ void ceph_san_logger_cleanup(void)
     spin_lock(&g_logger.lock);
     list_for_each_entry_safe(ctx, tmp, &g_logger.contexts, list) {
         list_del(&ctx->list);
-        cephsan_pagefrag_deinit(&ctx->pf);
-        kfree(ctx);
+        free_tls_ctx(ctx);
     }
     spin_unlock(&g_logger.lock);