diff options
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 342170b5ce1..fdf4b74240b 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -193,10 +193,10 @@ out: int32_t -sp_cache_get_entry (sp_cache_t *cache, char *name, gf_dirent_t *entry) +sp_cache_get_entry (sp_cache_t *cache, char *name, gf_dirent_t **entry) { int32_t ret = -1; - gf_dirent_t *tmp = NULL; + gf_dirent_t *tmp = NULL, *new = NULL; if ((cache == NULL) || (name == NULL) || (entry == NULL)) { goto out; @@ -206,10 +206,22 @@ sp_cache_get_entry (sp_cache_t *cache, char *name, gf_dirent_t *entry) { tmp = rbthash_get (cache->table, name, strlen (name)); if (tmp != NULL) { - memcpy (entry, tmp, sizeof (*entry)); + new = gf_dirent_for_name (tmp->d_name); + if (new == NULL) { + goto unlock; + } + + new->d_ino = tmp->d_ino; + new->d_off = tmp->d_off; + new->d_len = tmp->d_len; + new->d_type = tmp->d_type; + new->d_stat = tmp->d_stat; + + *entry = new; ret = 0; } } +unlock: UNLOCK (&cache->lock); out: @@ -721,7 +733,7 @@ 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) { - gf_dirent_t dirent; + gf_dirent_t *dirent = NULL; char entry_cached = 0; uint64_t value = 0; char xattr_req_empty = 1; @@ -771,7 +783,6 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) goto wind; } - memset (&dirent, 0, sizeof (dirent)); cache = sp_get_cache_inode (this, loc->parent, frame->root->pid); if (cache) { ret = sp_cache_get_entry (cache, (char *)loc->name, &dirent); @@ -780,11 +791,13 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) if ((ret == 0) && (value != 0)) { inode_ctx = (void *)(long)value; postparent = inode_ctx->stbuf; - buf = dirent.d_stat; + buf = dirent->d_stat; op_ret = 0; op_errno = 0; entry_cached = 1; - } + } + + FREE (dirent); } } else if (S_ISDIR (loc->inode->st_mode)) { cache = sp_get_cache_inode (this, loc->inode, frame->root->pid); @@ -795,11 +808,13 @@ sp_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) if ((ret == 0) && (value != 0)) { inode_ctx = (void *)(long)value; postparent = inode_ctx->stbuf; - buf = dirent.d_stat; + buf = dirent->d_stat; op_ret = 0; op_errno = 0; entry_cached = 1; } + + FREE (dirent); } } } |