From c4cba07caf188cae38ae4e3008526ea79e924abb Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 7 Oct 2009 10:08:17 +0000 Subject: performance/stat-prefetch: remove lookup-behind in sp_lookup. - lookup-behind should be done on-demand basis, in fops like open instead of in sp_lookup itself. This would reduce network traffic between client and server related to lookup, if the only use of lookup was to fetch stat structure. Signed-off-by: Anand V. Avati BUG: 284 (performance actually decreases for 'ls -l' on a directory containing large number of files with stat-prefetch loaded) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=284 --- .../performance/stat-prefetch/src/stat-prefetch.c | 60 ++-------------------- 1 file changed, 4 insertions(+), 56 deletions(-) (limited to 'xlators/performance') diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 24061ac78..d74316bdc 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -379,35 +379,6 @@ sp_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } -int32_t -sp_lookup_behind_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct stat *buf, dict_t *dict) -{ - sp_local_t *local = NULL; - sp_cache_t *cache = NULL; - - local = frame->local; - if (local == NULL) { - goto out; - } - - if ((op_ret == -1) && (op_errno = ENOENT)) { - cache = sp_get_cache_inode (this, local->loc.parent, - frame->root->pid); - - if (cache) { - sp_cache_remove_entry (cache, (char *)local->loc.name, - 0); - } - } - -out: - SP_STACK_DESTROY (frame); - return 0; -} - - int32_t sp_get_ancestors (char *path, char **parent, char **grand_parent) { @@ -508,13 +479,11 @@ sp_is_empty (dict_t *this, char *key, data_t *value, void *data) int32_t sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) { - sp_local_t *local = NULL; gf_dirent_t dirent; int32_t ret = -1, op_ret = -1, op_errno = EINVAL; sp_cache_t *cache = NULL; struct stat *postparent = NULL, *buf = NULL; - call_frame_t *wind_frame = NULL; - char lookup_behind = 0; + char entry_cached = 0; char xattr_req_empty = 1; if (loc == NULL) { @@ -541,7 +510,7 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) buf = &dirent.d_stat; op_ret = 0; op_errno = 0; - lookup_behind = 1; + entry_cached = 1; } } else if (S_ISDIR (loc->inode->st_mode)) { cache = sp_get_cache_inode (this, loc->inode, frame->root->pid); @@ -551,37 +520,16 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) buf = &dirent.d_stat; op_ret = 0; op_errno = 0; - lookup_behind = 1; + entry_cached = 1; } } } wind: - if (lookup_behind) { + if (entry_cached) { if (cache) { cache->hits++; } - - wind_frame = copy_frame (frame); - if (wind_frame == NULL) { - op_ret = -1; - op_errno = ENOMEM; - gf_log (this->name, GF_LOG_ERROR, "out of memory"); - goto unwind; - } - - local = CALLOC (1, sizeof (*local)); - if (local == NULL) { - op_ret = -1; - op_errno = ENOMEM; - STACK_DESTROY (wind_frame->root); - goto unwind; - } - - loc_copy (&local->loc, loc); - wind_frame->local = local; - STACK_WIND (wind_frame, sp_lookup_behind_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->lookup, loc, xattr_req); } else { if (cache) { cache->miss++; -- cgit