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/io-cache.h | 50 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'xlators/performance/io-cache/src/io-cache.h') diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h index 74a707147..49d3d000b 100644 --- a/xlators/performance/io-cache/src/io-cache.h +++ b/xlators/performance/io-cache/src/io-cache.h @@ -34,11 +34,14 @@ #include "xlator.h" #include "common-utils.h" #include "call-stub.h" +#include "rbthash.h" +#include "hashfn.h" #include #include #define IOC_PAGE_SIZE (1024 * 128) /* 128KB */ #define IOC_CACHE_SIZE (32 * 1024 * 1024) +#define IOC_PAGE_TABLE_BUCKET_COUNT 4096 struct ioc_table; struct ioc_local; @@ -110,7 +113,6 @@ struct ioc_local { * */ struct ioc_page { - struct list_head pages; struct list_head page_lru; struct ioc_inode *inode; /* inode this page belongs to */ struct ioc_priority *priority; @@ -125,28 +127,32 @@ struct ioc_page { pthread_mutex_t page_lock; }; +struct ioc_cache { + rbthash_table_t *page_table; + struct list_head page_lru; + time_t mtime; /* + * mtime of the server file when last + * cached + */ + struct timeval tv; /* + * time-stamp at last re-validate + */ +}; + struct ioc_inode { - struct ioc_table *table; - struct list_head pages; /* list of pages of this inode */ - struct list_head inode_list; /* - * list of inodes, maintained by io-cache - * translator - */ - struct list_head inode_lru; - struct list_head page_lru; - struct ioc_waitq *waitq; - pthread_mutex_t inode_lock; - uint32_t weight; /* - * weight of the inode, increases on each - * read - */ - time_t mtime; /* - * mtime of the server file when last - * cached - */ - struct timeval tv; /* - * time-stamp at last re-validate - */ + struct ioc_table *table; + struct ioc_cache cache; + struct list_head inode_list; /* + * list of inodes, maintained by + * io-cache translator + */ + struct list_head inode_lru; + struct ioc_waitq *waitq; + pthread_mutex_t inode_lock; + uint32_t weight; /* + * weight of the inode, increases + * on each read + */ }; struct ioc_table { -- cgit