dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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