From 53ff4f0299cf14c6c413d3e49991a6f05f9cda19 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 28 Oct 2009 18:42:35 +0000 Subject: libglusterfs/rbtree: change rbthash_init_table to take no of expected entries in the hash table as argument. - the expected number of entries is used to create the memory pool of the hash table. Having constant macro for this purpose is not suitable since different users of rbtree based hash table store different number of entries in the table. Signed-off-by: Anand V. Avati BUG: 335 (Io-cache optimization) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=335 --- xlators/performance/io-cache/src/ioc-inode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'xlators/performance/io-cache') diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index 356afc583..e647b3183 100644 --- a/xlators/performance/io-cache/src/ioc-inode.c +++ b/xlators/performance/io-cache/src/ioc-inode.c @@ -166,18 +166,23 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode, ioc_inode_t * ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight) { - ioc_inode_t *ioc_inode = NULL; - + ioc_inode_t *ioc_inode = NULL; + unsigned long no_of_pages = 0; + ioc_inode = CALLOC (1, sizeof (ioc_inode_t)); if (ioc_inode == NULL) { goto out; } ioc_inode->table = table; - + + no_of_pages = (table->cache_size / table->page_size) + + ((table->cache_size % table->page_size) ? 1 : 0); + /* initialize the list for pages */ ioc_inode->cache.page_table = rbthash_table_init (IOC_PAGE_TABLE_BUCKET_COUNT, - ioc_hashfn, NULL); + ioc_hashfn, NULL, + no_of_pages); if (ioc_inode->cache.page_table == NULL) { FREE (ioc_inode); ioc_inode = NULL; -- cgit