Blame SOURCES/0032-mem-cache-added-log-message-in-case-cache-is-full.patch

0ff280
From 2ad4aa8f265e02d01f77e5d29d8377d849c78d11 Mon Sep 17 00:00:00 2001
0ff280
From: Alexey Tikhonov <atikhono@redhat.com>
0ff280
Date: Wed, 4 Mar 2020 22:33:17 +0100
0ff280
Subject: [PATCH 32/35] mem-cache: added log message in case cache is full
0ff280
0ff280
Reviewed-by: Sumit Bose <sbose@redhat.com>
0ff280
---
0ff280
 src/responder/nss/nsssrv_mmap_cache.c | 22 ++++++++++++++++++++++
0ff280
 1 file changed, 22 insertions(+)
0ff280
0ff280
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
0ff280
index 5e23bbe6f..23df164da 100644
0ff280
--- a/src/responder/nss/nsssrv_mmap_cache.c
0ff280
+++ b/src/responder/nss/nsssrv_mmap_cache.c
0ff280
@@ -371,6 +371,20 @@ static bool sss_mc_is_valid_rec(struct sss_mc_ctx *mcc, struct sss_mc_rec *rec)
0ff280
     return true;
0ff280
 }
0ff280
 
0ff280
+static const char *mc_type_to_str(enum sss_mc_type type)
0ff280
+{
0ff280
+    switch (type) {
0ff280
+    case SSS_MC_PASSWD:
0ff280
+        return "PASSWD";
0ff280
+    case SSS_MC_GROUP:
0ff280
+        return "GROUP";
0ff280
+    case SSS_MC_INITGROUPS:
0ff280
+        return "INITGROUPS";
0ff280
+    default:
0ff280
+        return "-UNKNOWN-";
0ff280
+    }
0ff280
+}
0ff280
+
0ff280
 /* FIXME: This is a very simplistic, inefficient, memory allocator,
0ff280
  * it will just free the oldest entries regardless of expiration if it
0ff280
  * cycled the whole free bits map and found no empty slot */
0ff280
@@ -438,6 +452,14 @@ static errno_t sss_mc_find_free_slots(struct sss_mc_ctx *mcc,
0ff280
     } else {
0ff280
         cur = mcc->next_slot;
0ff280
     }
0ff280
+    if (cur == 0) {
0ff280
+        /* inform only once per full loop to avoid excessive spam */
0ff280
+        DEBUG(SSSDBG_IMPORTANT_INFO, "mmap cache of type '%s' is full\n",
0ff280
+              mc_type_to_str(mcc->type));
0ff280
+        sss_log(SSS_LOG_NOTICE, "mmap cache of type '%s' is full, if you see "
0ff280
+                "this message often then please consider increase of cache size",
0ff280
+                mc_type_to_str(mcc->type));
0ff280
+    }
0ff280
     for (i = 0; i < num_slots; i++) {
0ff280
         MC_PROBE_BIT(mcc->free_table, cur + i, used);
0ff280
         if (used) {
0ff280
-- 
0ff280
2.21.3
0ff280