Blob Blame Raw
From 82d69a381183cf5125ba8d4afdfd12c65544e348 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Sun, 31 May 2015 17:08:29 -0700
Subject: [PATCH 63/72] Ticket #48190 - idm/ipa 389-ds-base entry cache
 converges to 500 KB in dblayer_is_cachesize_sane

Description: This issue was introduced by the fix for Ticket 47499
commit 1e035d1111f6abcb87e760a2b9e41fa9e05a7ebd.

The function dblayer_is_cachesize_sane was originally implemented for
db cache to check if the given db cache size is larger than the available
memory or not.  The function resets the size to the available memory size
if it is larger.  Also, considering the extra metadata size needed for the
db cache, it multiplies by 0.8 every time it starts the server.  It is not
needed even for the db cache.  The code is old and we don't have to save
the memory there.  Thus, this patch removes the resetting code.

https://fedorahosted.org/389/ticket/48190

Reviewed by mreynolds@redhat.com (Thank you, Mark!!)

(cherry picked from commit bf9ef718cfd48c26eaf11662f522451d866e7681)
---
 ldap/servers/slapd/back-ldbm/dblayer.c              | 7 -------
 ldap/servers/slapd/back-ldbm/ldbm_instance_config.c | 6 ++++--
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 2524355..d3deff8 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1116,13 +1116,6 @@ int dblayer_is_cachesize_sane(size_t *cachesize)
     if (!issane) {
         *cachesize = (size_t)((pages - procpages) * pagesize);
     }
-    /* We now compensate for DB's own compensation for metadata size 
-     * They increase the actual cache size by 25%, but only for sizes
-     * less than 500Meg.
-     */
-    if (*cachesize < 500*MEGABYTE) {
-        *cachesize = (size_t)((double)*cachesize * (double)0.8);
-    }
     
     return issane;
 }
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
index 9b93f9a..f75ca97 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
@@ -121,11 +121,12 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
     ldbm_instance *inst = (ldbm_instance *) arg;
     int retval = LDAP_SUCCESS;
     size_t val = (size_t) value;
+    size_t chkval = val;
 
     /* Do whatever we can to make sure the data is ok. */
 
     if (apply) {
-        if (!dblayer_is_cachesize_sane(&val)){
+        if (!dblayer_is_cachesize_sane(&chkval)){
             PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
                     "Error: cachememsize value is too large.");
             LDAPDebug( LDAP_DEBUG_ANY,"Error: cachememsize value is too large.\n",
@@ -152,11 +153,12 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
     ldbm_instance *inst = (ldbm_instance *) arg;
     int retval = LDAP_SUCCESS;
     size_t val = (size_t)value;
+    size_t chkval = val;
 
     /* Do whatever we can to make sure the data is ok. */
 
     if (apply) {
-        if (!dblayer_is_cachesize_sane(&val)){
+        if (!dblayer_is_cachesize_sane(&chkval)){
             PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
                     "Error: dncachememsize value is too large.");
             LDAPDebug( LDAP_DEBUG_ANY,"Error: dncachememsize value is too large.\n",
-- 
1.9.3