From c8d7c99ec50c81a33eea43ed1c535fa4d65cef23 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Fri, 5 Aug 2011 12:24:33 -0700 Subject: [PATCH 1/1] LU-569: Make lu_object cache size adjustable lu_object cache is specified to consume 20% of total memory. This limits 200 clients at most can be mounted on one node. We should make it adjustable so that customers have a chance to configure it by their needs. Change-Id: I8dcb993c88a3abd9fc8ba11ff1578aa3897c3933 Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/1188 Tested-by: Hudson Reviewed-by: Oleg Drokin Tested-by: Maloo --- lustre/obdclass/lu_object.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index e430eb1..8c49f8c 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -754,9 +754,14 @@ void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie, EXPORT_SYMBOL(lu_site_print); enum { - LU_CACHE_PERCENT = 20, + LU_CACHE_PERCENT_MAX = 50, + LU_CACHE_PERCENT_DEFAULT = 20 }; +static unsigned int lu_cache_percent = LU_CACHE_PERCENT_DEFAULT; +CFS_MODULE_PARM(lu_cache_percent, "i", int, 0644, + "Percentage of memory to be used as lu_object cache"); + /** * Return desired hash table order. */ @@ -780,7 +785,16 @@ static int lu_htable_order(void) cache_size = 1 << (30 - CFS_PAGE_SHIFT) * 3 / 4; #endif - cache_size = cache_size / 100 * LU_CACHE_PERCENT * + /* clear off unreasonable cache setting. */ + if (lu_cache_percent == 0 || lu_cache_percent > LU_CACHE_PERCENT_MAX) { + CWARN("obdclass: invalid lu_cache_percent: %u, it must be in" + " the range of (0, %u]. Will use default value: %u.\n", + lu_cache_percent, LU_CACHE_PERCENT_MAX, + LU_CACHE_PERCENT_DEFAULT); + + lu_cache_percent = LU_CACHE_PERCENT_DEFAULT; + } + cache_size = cache_size / 100 * lu_cache_percent * (CFS_PAGE_SIZE / 1024); for (bits = 1; (1 << bits) < cache_size; ++bits) { -- 1.8.3.1