From: Alex Markuze Date: Sun, 16 Mar 2025 18:38:49 +0000 (+0000) Subject: minor fixups X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ba82b5f31d49228116bf968a29885b861369111;p=ceph-client.git minor fixups --- diff --git a/net/ceph/ceph_san_batch.c b/net/ceph/ceph_san_batch.c index 4b3c37850434..08d33bc79900 100644 --- a/net/ceph/ceph_san_batch.c +++ b/net/ceph/ceph_san_batch.c @@ -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; diff --git a/net/ceph/ceph_san_logger.c b/net/ceph/ceph_san_logger.c index 95582fbada85..7726a539ce0a 100644 --- a/net/ceph/ceph_san_logger.c +++ b/net/ceph/ceph_san_logger.c @@ -7,6 +7,7 @@ #include #include +#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);