summaryrefslogtreecommitdiffstats
path: root/xlators/performance/stat-prefetch/src/stat-prefetch.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-10-08 06:21:53 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-09 00:50:07 -0700
commit3fb8e1d67a7d2a4513fa96df726f557fb5aa3df5 (patch)
treeecdca1e31c5c064d9def86fe5bb694ca591320cc /xlators/performance/stat-prefetch/src/stat-prefetch.c
parent94f24f06644b9e872f4b34f100017672b5d08978 (diff)
performance/stat-prefetch: implement sp_entrylk.
- lookup on path should be sent in entrylk 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/stat-prefetch/src/stat-prefetch.c')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index 2b9954dbb4c..4b2a8f0b515 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -3419,6 +3419,90 @@ out:
int32_t
+sp_entrylk_helper (call_frame_t *frame, xlator_t *this, const char *volume,
+ loc_t *loc, const char *basename, entrylk_cmd cmd,
+ entrylk_type type)
+{
+ 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_err_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->entrylk, volume, loc, basename,
+ cmd, type);
+
+ return 0;
+
+unwind:
+ SP_STACK_UNWIND (frame, -1, op_errno);
+ return 0;
+}
+
+
+int32_t
+sp_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc,
+ const char *basename, entrylk_cmd cmd, entrylk_type type)
+{
+ 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, out, op_errno,
+ EINVAL);
+ GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, loc->inode, out,
+ op_errno, EINVAL);
+
+ stub = fop_entrylk_stub (frame, sp_entrylk_helper, volume, loc,
+ basename, cmd, type);
+ if (stub == NULL) {
+ op_errno = ENOMEM;
+ gf_log (this->name, GF_LOG_ERROR, "out of memory");
+ goto out;
+ }
+
+ 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_err_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->entrylk, volume, loc,
+ basename, cmd, type);
+ }
+
+ return 0;
+}
+
+
+int32_t
sp_forget (xlator_t *this, inode_t *inode)
{
struct stat *buf = NULL;
@@ -3516,6 +3600,7 @@ struct xlator_fops fops = {
.access = sp_access,
.getxattr = sp_getxattr,
.inodelk = sp_inodelk,
+ .entrylk = sp_entrylk,
};
struct xlator_mops mops = {