summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-18 00:29:05 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-19 01:15:39 -0800
commitd14d014782dd4d7023f99a054d0c4db37d020435 (patch)
tree510c2c103b059f1cf8e791b4eeda1ac4de7d1d9a /xlators
parent892710a37abcb10fdcff395a4369efce2af4c63f (diff)
performance/stat-prefetch: don't use pre-allocated dirent structure in sp_get_cache_entry.
- since we don't know the size of dentry before calling sp_get_cache_entry, we must dynamically allocate the dentry in sp_cache_get_entry and copy the contents from cache. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 371 (rm -rf fails on stat-prefetch.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=371
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c31
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 342170b5c..fdf4b7424 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);
}
}
}