diff options
author | Raghavendra G <raghavendra@gluster.com> | 2009-08-23 22:29:41 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-09-08 01:41:18 -0700 |
commit | ded6f40765a34dce2ec49d1b643770f110882b15 (patch) | |
tree | 1b67770461f5100fe59073ab7c44ed1bcd851cd5 /xlators | |
parent | b0d3d94b8ca94d1a133f74050d078a4bd6fa5260 (diff) |
performance/stat-prefetch: implement sp_open.
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')
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index a35d30e641f..903bea99e42 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -602,6 +602,63 @@ unwind: int32_t +sp_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, fd_t *fd) +{ + sp_local_t *local = NULL; + sp_fd_ctx_t *fd_ctx = NULL; + + if (op_ret == -1) { + goto out; + } + + local = frame->local; + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, out, EINVAL); + + fd_ctx = sp_fd_ctx_new (this, local->loc.parent, + (char *)local->loc.name, NULL); + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, fd_ctx, out, ENOMEM); + + op_ret = fd_ctx_set (fd, this, (long)(void *)fd_ctx); + if (op_ret == -1) { + sp_fd_ctx_free (fd_ctx); + op_errno = ENOMEM; + } + +out: + SP_STACK_UNWIND (frame, op_ret, op_errno, fd); + return 0; +} + + +int32_t +sp_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd) +{ + sp_local_t *local = NULL; + int32_t ret = -1; + + local = CALLOC (1, sizeof (*local)); + GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, unwind, ENOMEM); + + frame->local = local; + + ret = loc_copy (&local->loc, loc); + if (ret == -1) { + goto unwind; + } + + STACK_WIND (frame, sp_fd_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->open, loc, flags, fd); + return 0; + +unwind: + SP_STACK_UNWIND (frame, -1, errno, fd); + return 0; +} + + +int32_t sp_forget (xlator_t *this, inode_t *inode) { struct stat *buf = NULL; @@ -646,6 +703,7 @@ struct xlator_fops fops = { .lookup = sp_lookup, .readdir = sp_readdir, .chmod = sp_chmod, + .open = sp_open, }; struct xlator_mops mops = { |