From 96ac4559414035288fa18e72a21628ea3cdf6a4c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Thu, 19 Nov 2009 17:28:00 +0000 Subject: performance/io-cache: don't use stat got in read_cbk if it is zero-filled. - translators like io-cache, read-ahead return a zero-filled stbuf in readv_cbk and usage of zero filled stat for cache validation is not correct. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 376 (server-side io-cache is preventing client-side io-cache from working) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=376 --- xlators/performance/io-cache/src/io-cache.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'xlators/performance/io-cache/src/io-cache.c') diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 84b184993..59eaf4c03 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -179,18 +179,20 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, inode_ctx_get (inode, this, &tmp_ioc_inode); ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode; if (ioc_inode) { + ioc_inode_lock (ioc_inode); + { + if (ioc_inode->cache.mtime == 0) { + ioc_inode->cache.mtime = stbuf->st_mtime; + } + } + ioc_inode_unlock (ioc_inode); + cache_still_valid = ioc_cache_still_valid (ioc_inode, stbuf); if (!cache_still_valid) { ioc_inode_flush (ioc_inode); } - /* update the time-stamp of revalidation */ - ioc_inode_lock (ioc_inode); - { - gettimeofday (&ioc_inode->cache.tv, NULL); - } - ioc_inode_unlock (ioc_inode); ioc_table_lock (ioc_inode->table); { @@ -468,6 +470,7 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, ioc_inode = ioc_inode_update (table, inode, weight); + __inode_ctx_put (fd->inode, this, (uint64_t)(long)ioc_inode); } else { @@ -549,6 +552,12 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ioc_inode = ioc_inode_update (table, inode, weight); + ioc_inode_lock (ioc_inode); + { + ioc_inode->cache.mtime = buf->st_mtime; + } + ioc_inode_unlock (ioc_inode); + inode_ctx_put (fd->inode, this, (uint64_t)(long)ioc_inode); } -- cgit