diff options
author | Vijay Bellur <vijay@gluster.com> | 2009-12-01 12:03:08 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-12-01 17:52:47 -0800 |
commit | 933e87700e25e83bcd5e9ba4c4f580d48fcaccee (patch) | |
tree | 387aae41ae3723755db955c91076638ac6f8f408 /xlators/performance/io-cache | |
parent | 6afe4faeaa77911490b2eca0830928367543e504 (diff) |
performance/io-cache: Hold locks on inode before creating rbt tree.
Lock is held before creating a RBT in inode. Also, did some re-factoring.
Signed-off-by: Vijay Bellur <vijay@gluster.com>
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')
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 3fb4c850efd..13811b628b1 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -921,35 +921,44 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, ioc_table_lock (table); - if (!table->mem_pool) { + { + if (!table->mem_pool) { - num_pages = (table->cache_size / table->page_size) - + ((table->cache_size % table->page_size) ? 1 : 0); + 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); + 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; + 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); - if (!ioc_inode->cache.page_table) { - ioc_inode->cache.page_table - = rbthash_table_init (IOC_PAGE_TABLE_BUCKET_COUNT, - ioc_hashfn, NULL, 0, - table->mem_pool); - - if (ioc_inode->cache.page_table == NULL) { - op_errno = ENOMEM; - goto out; + ioc_inode_lock (ioc_inode); + { + if (!ioc_inode->cache.page_table) { + ioc_inode->cache.page_table + = rbthash_table_init + (IOC_PAGE_TABLE_BUCKET_COUNT, + ioc_hashfn, NULL, 0, + table->mem_pool); + + if (ioc_inode->cache.page_table == NULL) { + op_errno = ENOMEM; + ioc_inode_unlock (ioc_inode); + goto out; + } } } + ioc_inode_unlock (ioc_inode); if (!fd_ctx_get (fd, this, NULL)) { /* disable caching for this fd, go ahead with normal readv */ |