diff options
Diffstat (limited to 'xlators/performance/io-cache')
| -rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 21 | ||||
| -rw-r--r-- | xlators/performance/io-cache/src/page.c | 24 | 
2 files changed, 29 insertions, 16 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 84b18499352..59eaf4c03c3 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);  		} diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index 4f9e76cb271..475a095e6d4 100644 --- a/xlators/performance/io-cache/src/page.c +++ b/xlators/performance/io-cache/src/page.c @@ -285,7 +285,7 @@ int8_t  ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct stat *stbuf)  {  	int8_t cache_still_valid = 1; -   +  #if 0  	if (!stbuf || (stbuf->st_mtime != ioc_inode->cache.mtime) ||   	    (stbuf->st_mtim.tv_nsec != ioc_inode->stbuf.st_mtim.tv_nsec)) @@ -342,31 +342,35 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,  	size_t      page_size = 0;  	ioc_waitq_t *waitq = NULL;          size_t      iobref_page_size = 0; +        char        zero_filled = 0;          local = frame->local;          offset = local->pending_offset;          ioc_inode = local->inode;          table = ioc_inode->table; -	trav_offset = offset;   +	trav_offset = offset;  	payload_size = op_ret; +        zero_filled = ((op_ret >=0) +                       && (stbuf->st_mtime == 0)); +  	ioc_inode_lock (ioc_inode);  	{ -		if (op_ret == -1 ||  -		    (op_ret >= 0 &&  -		     !ioc_cache_still_valid(ioc_inode, stbuf))) { +		if (op_ret == -1 || +		    !(zero_filled || +                      ioc_cache_still_valid(ioc_inode, stbuf))) {  			gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE,  				"cache for inode(%p) is invalid. flushing "  				"all pages", ioc_inode);  			destroy_size = __ioc_inode_flush (ioc_inode); -		}  -     -		if (op_ret >= 0) +		} + +		if ((op_ret >= 0) && !zero_filled)  			ioc_inode->cache.mtime = stbuf->st_mtime; -     +  		gettimeofday (&ioc_inode->cache.tv, NULL); -     +  		if (op_ret < 0) {  			/* error, readv returned -1 */  			page = ioc_page_get (ioc_inode, offset);  | 
