From 81af21adec38eb04de19694af1b3ce8a1a095ab7 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 24 Nov 2009 20:46:34 +0000 Subject: performance/stat-prefetch: don't free the cache in readdir if the offset is not the expected one. - cache creation is expensive operation. Also, cache will be freed in releasedir. Hence, just remove all entries from cache without freeing the cache. However this is not entirely true, since sp_cache_remove_entry frees the old table and reinitializes a new table if all entries are being removed. When rbtree based hash table provides an interface to remove all the entries, sp_cache_remove_entry should be modified not to destroy the table. - this patch also fixes a race condition wherein the cache being used in lookup getting freed in readdir if the offset is not equal to expected offset. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 405 (Segmentation fault in stat-prefetch.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=405 --- xlators/performance/stat-prefetch/src/stat-prefetch.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'xlators/performance/stat-prefetch') diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index abfc6175617..9c6f44f0de8 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -934,10 +934,7 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, cache = sp_get_cache_fd (this, fd); if (cache) { if (off != cache->expected_offset) { - cache = sp_del_cache_fd (this, fd); - if (cache) { - sp_cache_free (cache); - } + sp_cache_remove_entry (cache, NULL, 1); } } @@ -945,7 +942,7 @@ sp_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (ret == -1) { goto unwind; } - + ret = sp_cache_remove_parent_entry (frame, this, path); FREE (path); -- cgit