From 96fb35624060565e02e946a970b3e777071bde9c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Thu, 24 Nov 2016 14:58:20 +0530 Subject: performance/readdir-ahead: limit cache size This patch introduces a new option called "rda-cache-limit", which is the maximum value the entire readdir-ahead cache can grow into. Since, readdir-ahead holds a reference to inode through dentries, this patch also accounts memory stored by various xlators in inode contexts. Change-Id: I84cc0ca812f35e0f9041f8cc71effae53a9e7f99 BUG: 1356960 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/16137 NetBSD-regression: NetBSD Build System Reviewed-by: Poornima G Smoke: Gluster Build System CentOS-regression: Gluster Build System --- libglusterfs/src/inode.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'libglusterfs/src/inode.c') diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 6e4c2f11bc2..841f0b63f16 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -2504,3 +2504,35 @@ out: return; } + +size_t +inode_ctx_size (inode_t *inode) +{ + int i = 0; + size_t size = 0; + xlator_t *xl = NULL, *old_THIS = NULL; + + if (!inode) + goto out; + + LOCK (&inode->lock); + { + for (i = 0; i < inode->table->ctxcount; i++) { + if (!inode->_ctx[i].xl_key) + continue; + + xl = (xlator_t *)(long)inode->_ctx[i].xl_key; + old_THIS = THIS; + THIS = xl; + + if (xl->cbks->ictxsize) + size += xl->cbks->ictxsize (xl, inode); + + THIS = old_THIS; + } + } + UNLOCK (&inode->lock); + +out: + return size; +} -- cgit