diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-10-08 06:21:35 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-10-09 00:49:22 -0700 |
commit | 9857c10cd6b7b4497f8bc2d96aa559d1191f65d8 (patch) | |
tree | 5bbc283769b792db0c0734fde08a6b7234e317a6 /xlators/performance | |
parent | 19322c4a2a2c439a7c90dabe07cee07deb9dc79a (diff) |
performance/stat-prefetch: lookup path in unlink if it is not already looked up.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 221 (stat prefetch implementation)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 82 |
1 files changed, 70 insertions, 12 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index be2f9a5ab..3ecb89758 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1782,16 +1782,59 @@ sp_err_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t +sp_unlink_helper (call_frame_t *frame, xlator_t *this, loc_t *loc) +{ + 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_unlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, loc); + + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, op_errno); + return 0; +} + + +int32_t sp_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) { - sp_cache_t *cache = NULL; - int32_t ret = 0, op_errno = EINVAL; + sp_cache_t *cache = NULL; + int32_t ret = -1, 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); cache = sp_get_cache_inode (this, loc->parent, frame->root->pid); @@ -1803,16 +1846,31 @@ sp_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) if (ret == -1) { op_errno = ENOMEM; gf_log (this->name, GF_LOG_ERROR, "out of memory"); - goto unwind; + goto out; } - STACK_WIND (frame, sp_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->unlink, loc); - return 0; + stub = fop_unlink_stub (frame, sp_unlink_helper, loc); + if (stub == NULL) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; + } -unwind: - SP_STACK_UNWIND (frame, -1, op_errno); - return 0; + 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); + } 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_unlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, loc); + } + + return 0; } |