From 4199ac7e9417abe8a38a6333f0f0395ecef1e6d2 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 7 Oct 2009 10:09:08 +0000 Subject: performance/stat-prefetch: do lookup in mknod if the path is not already looked up. Signed-off-by: Anand V. Avati 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 --- .../performance/stat-prefetch/src/stat-prefetch.c | 88 ++++++++++++++++++---- 1 file changed, 75 insertions(+), 13 deletions(-) (limited to 'xlators/performance/stat-prefetch') diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 00271057b..15fbaa620 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -1279,38 +1279,100 @@ unwind: } +int32_t +sp_mknod_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev) +{ + 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) && (op_errno != ENOENT)) + || (op_ret == 0)) { + if (op_ret == 0) { + op_ret = -1; + op_errno = EEXIST; + } + goto unwind; + } + + STACK_WIND (frame, sp_new_entry_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->mknod, loc, mode, rdev); + + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, op_errno, NULL); + return 0; +} + + int32_t sp_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dev_t rdev) { - int32_t ret = 0; - int32_t op_errno = -1; + int32_t op_errno = -1, ret = -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->path, unwind, op_errno, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->path, 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, unwind, + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out, op_errno, EINVAL); ret = sp_cache_remove_parent_entry (frame, this, (char *)loc->path); if (ret == -1) { op_errno = errno; gf_log (this->name, GF_LOG_ERROR, "%s", strerror (errno)); - goto unwind; + goto out; } - STACK_WIND (frame, sp_new_entry_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->mknod, loc, mode, rdev); + stub = fop_mknod_stub (frame, sp_mknod_helper, loc, mode, rdev); + 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, loc, stub, &need_unwind, + &need_lookup, &can_wind, &op_errno); -unwind: - SP_STACK_UNWIND (frame, -1, op_errno, loc->inode, NULL); +out: + if (need_unwind) { + SP_STACK_UNWIND (frame, -1, op_errno, NULL, 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_new_entry_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->mknod, loc, mode, rdev); + } + return 0; } -- cgit