From ded6f40765a34dce2ec49d1b643770f110882b15 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Sun, 23 Aug 2009 22:29:41 +0000 Subject: performance/stat-prefetch: implement sp_open. Signed-off-by: Anand V. Avati BUG: 221 (stat prefetch implementation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221 --- .../performance/stat-prefetch/src/stat-prefetch.c | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'xlators') 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 @@ -601,6 +601,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) { @@ -646,6 +703,7 @@ struct xlator_fops fops = { .lookup = sp_lookup, .readdir = sp_readdir, .chmod = sp_chmod, + .open = sp_open, }; struct xlator_mops mops = { -- cgit