summaryrefslogtreecommitdiffstats
path: root/xlators/performance/stat-prefetch
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-24 20:46:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-24 23:06:09 -0800
commit81af21adec38eb04de19694af1b3ce8a1a095ab7 (patch)
tree9d9eafec207e0f8e9499a957e7716b5733a3226d /xlators/performance/stat-prefetch
parent250edc9e494fe0c59eff580df18080111ecb475e (diff)
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 <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 405 (Segmentation fault in stat-prefetch.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=405
Diffstat (limited to 'xlators/performance/stat-prefetch')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index abfc61756..9c6f44f0d 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);