diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-10-07 10:09:02 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-10-07 23:04:54 -0700 |
commit | 2b2651db6fa5f3c644b9ab64874e37ffb966dd92 (patch) | |
tree | 8db3ec85f4c14992f712acb37db9dea172b8ece6 | |
parent | 697bbe4e15b6c080ea1874748807ab2b39ec8ffd (diff) |
performance/stat-prefetch: do lookup in utimens if the path is not already looked up
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
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
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index bdee24fd900..2d8bae1cdcb 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1672,30 +1672,91 @@ unwind: int32_t +sp_utimens_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, + struct timespec tv[2]) +{ + uint64_t value = 0; + sp_inode_ctx_t *inode_ctx = NULL; + int32_t ret = 0, op_ret = -1, op_errno = -1; + + ret = inode_ctx_get (loc->inode, this, &value); + if (ret == -1) { + gf_log (this->name, GF_LOG_DEBUG, "context not set in inode " + "(%p)", loc->inode); + op_errno = EINVAL; + goto unwind; + } + + inode_ctx = (sp_inode_ctx_t *)(long) value; + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, inode_ctx, unwind, op_errno, + EINVAL); + + LOCK (&inode_ctx->lock); + { + op_ret = inode_ctx->op_ret; + op_errno = inode_ctx->op_errno; + } + UNLOCK (&inode_ctx->lock); + + if (op_ret == -1) { + goto unwind; + } + + STACK_WIND (frame, sp_stbuf_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->utimens, loc, tv); + + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, op_errno, NULL); + return 0; +} + + +int32_t sp_utimens (call_frame_t *frame, xlator_t *this, loc_t *loc, struct timespec tv[2]) { - sp_cache_t *cache = NULL; - int32_t op_errno = -1; + sp_cache_t *cache = NULL; + int32_t op_errno = -1; + call_stub_t *stub = NULL; + char can_wind = 0, need_lookup = 0, need_unwind = 1; - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc, unwind, op_errno, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->parent, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->parent, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->name, unwind, op_errno, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->name, out, op_errno, EINVAL); + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out, + op_errno, EINVAL); cache = sp_get_cache_inode (this, loc->parent, frame->root->pid); if (cache) { sp_cache_remove_entry (cache, (char *)loc->name, 0); } - STACK_WIND (frame, sp_stbuf_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->utimens, loc, tv); - return 0; + stub = fop_utimens_stub (frame, sp_utimens_helper, loc, tv); + if (stub == NULL) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; + } -unwind: - SP_STACK_UNWIND (frame, -1, errno, NULL); + sp_process_inode_ctx (frame, this, loc, stub, &need_unwind, + &need_lookup, &can_wind, &op_errno); + +out: + if (need_unwind) { + SP_STACK_UNWIND (frame, -1, op_errno, NULL); + } else if (need_lookup) { + STACK_WIND (frame, sp_lookup_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->lookup, loc, NULL); + } else if (can_wind) { + STACK_WIND (frame, sp_stbuf_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->utimens, loc, tv); + } + return 0; } |