From 522c1eb4d2f5faf1fa87be07d9617df1439fc0d6 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Wed, 20 Jan 2016 12:17:28 +1100 Subject: [PATCH] LU-7689 obdclass: limit lu_site hash table size on clients Allocating a big hash table using the formula for osd does not really work for clients. We will create new hash table for each mount on a single client which is a lot of memory more than expected. This patch limits the hash table up to 8M on clients, which has 524288 entries. Signed-off-by: Li Dongyang Change-Id: I908fda102ec5fd46c1325e0e41f5fe291aaa3378 Reviewed-on: http://review.whamcloud.com/18048 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/obdclass/lu_object.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 6c82855..e04654c 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -69,6 +69,7 @@ enum { #define LU_SITE_BITS_MIN 12 #define LU_SITE_BITS_MAX 24 +#define LU_SITE_BITS_MAX_CL 19 /** * total 256 buckets, we don't want too many buckets because: * - consume too much memory @@ -921,6 +922,7 @@ static unsigned long lu_htable_order(struct lu_device *top) { unsigned long cache_size; unsigned long bits; + unsigned long bits_max = LU_SITE_BITS_MAX; /* * For ZFS based OSDs the cache should be disabled by default. This @@ -934,6 +936,9 @@ static unsigned long lu_htable_order(struct lu_device *top) return LU_SITE_BITS_MIN; } + if (strcmp(top->ld_type->ldt_name, LUSTRE_VVP_NAME) == 0) + bits_max = LU_SITE_BITS_MAX_CL; + /* * Calculate hash table size, assuming that we want reasonable * performance when 20% of total memory is occupied by cache of @@ -964,7 +969,8 @@ static unsigned long lu_htable_order(struct lu_device *top) for (bits = 1; (1 << bits) < cache_size; ++bits) { ; } - return bits; + + return clamp_t(typeof(bits), bits, LU_SITE_BITS_MIN, bits_max); } static unsigned lu_obj_hop_hash(struct cfs_hash *hs, @@ -1060,10 +1066,8 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) memset(s, 0, sizeof *s); mutex_init(&s->ls_purge_mutex); - bits = lu_htable_order(top); snprintf(name, sizeof(name), "lu_site_%s", top->ld_type->ldt_name); - for (bits = clamp_t(typeof(bits), bits, - LU_SITE_BITS_MIN, LU_SITE_BITS_MAX); + for (bits = lu_htable_order(top); bits >= LU_SITE_BITS_MIN; bits--) { s->ls_obj_hash = cfs_hash_create(name, bits, bits, bits - LU_SITE_BKT_BITS, -- 1.8.3.1