diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-10-26 03:01:33 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-10-28 01:46:27 -0700 |
commit | 3809bb1bbd617dbde1d943dbcf6b0346329187b6 (patch) | |
tree | c326390674d9120a731d01345d842e0e803e739a /xlators/performance/io-cache/src/ioc-inode.c | |
parent | 78d281d6026ad1ebe8cc65c4396055902369ea89 (diff) |
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 <avati@dev.gluster.com>
BUG: 335 (Io-cache optimization)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=335
Diffstat (limited to 'xlators/performance/io-cache/src/ioc-inode.c')
-rw-r--r-- | xlators/performance/io-cache/src/ioc-inode.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index 23c25be1f36..7260def418e 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); |