From 204ab142977163f634cbf4ec92be58754225504a Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Thu, 8 Mar 2012 07:45:15 +0530 Subject: performance/io-cache: move mem-pool initialisation to init. mem-pool is global structure which is stored in ioc-inode-table and hence can be initialised in init. Change-Id: I4bc88fe3e8c729312e41f62c98f665af5fb26a62 BUG: 765340 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.com/2895 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Vijay Bellur --- xlators/performance/io-cache/src/io-cache.c | 37 ++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'xlators/performance/io-cache') diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index bea22268b..823bac38d 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -1091,7 +1091,6 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, ioc_local_t *local = NULL; uint32_t weight = 0; ioc_table_t *table = NULL; - uint32_t num_pages = 0; int32_t op_errno = -1; if (!this) { @@ -1118,29 +1117,6 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, goto out; } - - ioc_table_lock (table); - { - if (!table->mem_pool) { - - num_pages = (table->cache_size / table->page_size) - + ((table->cache_size % table->page_size) - ? 1 : 0); - - table->mem_pool - = mem_pool_new (rbthash_entry_t, num_pages); - - if (!table->mem_pool) { - gf_log (this->name, GF_LOG_ERROR, - "Unable to allocate mem_pool"); - op_errno = ENOMEM; - ioc_table_unlock (table); - goto out; - } - } - } - ioc_table_unlock (table); - ioc_inode_lock (ioc_inode); { if (!ioc_inode->cache.page_table) { @@ -1672,6 +1648,7 @@ init (xlator_t *this) int32_t ret = -1; glusterfs_ctx_t *ctx = NULL; data_t *data = 0; + uint32_t num_pages = 0; xl_options = this->options; @@ -1757,6 +1734,18 @@ init (xlator_t *this) pthread_mutex_init (&table->table_lock, NULL); this->private = table; + + num_pages = (table->cache_size / table->page_size) + + ((table->cache_size % table->page_size) + ? 1 : 0); + + table->mem_pool = mem_pool_new (rbthash_entry_t, num_pages); + if (!table->mem_pool) { + gf_log (this->name, GF_LOG_ERROR, + "Unable to allocate mem_pool"); + goto out; + } + ret = 0; ctx = this->ctx; -- cgit