diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-10-08 06:21:42 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-10-09 00:49:37 -0700 |
commit | 7fcb479dc329d9931c0ec975ab8b87450d6d8b24 (patch) | |
tree | 953beb750c2ec41edd7117c7f513390fab79b9d4 /xlators/performance/stat-prefetch/src/stat-prefetch.c | |
parent | aa8323817ebacf664b0e4c68996efa5847342bf8 (diff) |
performance/stat-prefetch: lookup oldloc->path in link if it has not already been 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/stat-prefetch/src/stat-prefetch.c')
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 95 |
1 files changed, 83 insertions, 12 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index baa6fa6db14..eef56a7719c 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1472,35 +1472,106 @@ out: int32_t +sp_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc, + loc_t *newloc) +{ + 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 (oldloc->inode, this, &value); + if (ret == -1) { + gf_log (this->name, GF_LOG_DEBUG, "context not set in inode " + "(%p)", oldloc->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_new_entry_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->link, oldloc, newloc); + + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL, NULL); + return 0; +} + + +int32_t sp_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc) { - int32_t ret = 0, op_errno = EINVAL; + call_stub_t *stub = NULL; + int32_t ret = 0, op_errno = -1; + char can_wind = 0, need_lookup = 0, need_unwind = 1; - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc, unwind, op_errno, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->parent, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->parent, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->path, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->path, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->name, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->name, out, op_errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->inode, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->inode, out, + op_errno, EINVAL); + + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc, out, op_errno, + EINVAL); + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, newloc->parent, out, op_errno, EINVAL); ret = sp_cache_remove_parent_entry (frame, this, (char *)newloc->path); if (ret == -1) { op_errno = ENOMEM; gf_log (this->name, GF_LOG_ERROR, "out of memory"); - goto unwind; + goto out; } - STACK_WIND (frame, sp_new_entry_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->link, oldloc, newloc); + stub = fop_link_stub (frame, sp_link_helper, oldloc, newloc); + if (stub == NULL) { + op_errno = ENOMEM; + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; + } - return 0; + sp_process_inode_ctx (frame, this, oldloc, stub, &need_unwind, + &need_lookup, &can_wind, &op_errno); -unwind: - SP_STACK_UNWIND (frame, -1, op_errno, oldloc->inode, NULL); + /* + * no need to process context in newloc->inode for following reasons: + * 1. if dentry corresponding to newloc->path was cached, sp_lookup + * would've unwound indicating success and link fop itself would've + * not been called. + * 2. if dentry corresponding to newloc->path was not cached, lookup + * would've anyways be sent to underlying translators in sp_lookup. + */ +out: + if (need_unwind) { + SP_STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL, NULL); + } else if (need_lookup) { + STACK_WIND (frame, sp_lookup_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->lookup, oldloc, NULL); + } else if (can_wind) { + STACK_WIND (frame, sp_new_entry_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->link, oldloc, newloc); + } + return 0; } |