summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-10-08 06:21:10 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-09 00:48:41 -0700
commit8260e8c1ec061ea8fadc79695f5269781d543376 (patch)
treef3dac5ff26945da78d379006be9cd0acf28352df
parentf89f4c64af2d9253dea28504d9f27bf08b544bf0 (diff)
performance/stat-prefetch: implement procedure sp_process_inode_ctx.
- this procedure processes inode_ctx to make decisions like whether the current procedure can continue (i.e., inode is already looked up), or the procedure has to initiate/wait for lookup on the path. It also sets up the frame->local and adds the stub corresponding to current fop if needed. 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
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index 794d1e8c7..1da4d0f11 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -21,6 +21,99 @@
#define GF_SP_CACHE_BUCKETS 4096
+int32_t
+sp_process_inode_ctx (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ call_stub_t *stub, char *need_unwind, char *need_lookup,
+ char *can_wind, int32_t *error)
+{
+ int32_t ret = -1, op_errno = -1;
+ sp_local_t *local = NULL;
+ sp_inode_ctx_t *inode_ctx = NULL;
+ uint64_t value = 0;
+
+ if (need_unwind != NULL) {
+ *need_unwind = 1;
+ }
+
+ if ((this == NULL) || (loc == NULL) || (loc->inode == NULL)
+ || (need_unwind == NULL) || (need_lookup == NULL)
+ || (can_wind == NULL)) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ 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);
+ *can_wind = 1;
+ *need_unwind = 0;
+ op_errno = 0;
+ ret = 0;
+ goto out;
+ }
+
+ inode_ctx = (sp_inode_ctx_t *)(long) value;
+ GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, inode_ctx, out, op_errno,
+ EINVAL);
+
+ LOCK (&inode_ctx->lock);
+ {
+ if (inode_ctx->op_ret == -1) {
+ op_errno = inode_ctx->op_errno;
+ goto unlock;
+ }
+
+ if (!(inode_ctx->looked_up || inode_ctx->lookup_in_progress)) {
+ *need_lookup = 1;
+ inode_ctx->lookup_in_progress = 1;
+
+ if (frame->local == NULL) {
+ local = CALLOC (1, sizeof (*local));
+ GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name,
+ local,
+ unlock,
+ op_errno,
+ ENOMEM);
+
+ frame->local = local;
+
+ ret = loc_copy (&local->loc, loc);
+ if (ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR, "%s",
+ strerror (op_errno));
+ goto unlock;
+ }
+ }
+ }
+
+ if (inode_ctx->looked_up) {
+ *can_wind = 1;
+ } else {
+ list_add_tail (&stub->list, &inode_ctx->waiting_ops);
+ stub = NULL;
+ }
+
+ *need_unwind = 0;
+ ret = 0;
+ }
+unlock:
+ UNLOCK (&inode_ctx->lock);
+
+out:
+ if (stub != NULL) {
+ call_stub_destroy (stub);
+ }
+
+ if (error != NULL) {
+ *error = op_errno;
+ }
+
+ return ret;
+}
+
+
inline uint32_t
sp_hashfn (void *data, int len)
{