From 3809bb1bbd617dbde1d943dbcf6b0346329187b6 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 26 Oct 2009 03:01:33 +0000 Subject: performance/io-cache: change data structure used to store page-cache. - io-cache uses rbtree based hash tables to store page-cache instead of lists. 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 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'xlators/performance/io-cache/src/ioc-inode.c') diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index 23c25be1f..7260def41 100644 --- a/xlators/performance/io-cache/src/ioc-inode.c +++ b/xlators/performance/io-cache/src/ioc-inode.c @@ -25,6 +25,19 @@ #include "io-cache.h" +inline uint32_t +ioc_hashfn (void *data, int len) +{ + uint32_t hash = 0; + while (len > 0) { + hash ^= *(uint32_t *)data; + data += sizeof (uint32_t); + len -= sizeof (uint32_t); + } + + return hash; +} + /* * str_to_ptr - convert a string to pointer * @string: string @@ -163,8 +176,15 @@ ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight) ioc_inode->table = table; /* initialize the list for pages */ - INIT_LIST_HEAD (&ioc_inode->pages); - INIT_LIST_HEAD (&ioc_inode->page_lru); + ioc_inode->cache.page_table = rbthash_table_init (IOC_PAGE_TABLE_BUCKET_COUNT, + ioc_hashfn, free); + if (ioc_inode->cache.page_table == NULL) { + FREE (ioc_inode); + ioc_inode = NULL; + goto out; + } + + INIT_LIST_HEAD (&ioc_inode->cache.page_lru); ioc_table_lock (table); -- cgit