diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-07-09 00:26:47 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-07-16 00:37:45 -0700 |
commit | 8579b0edbc8c6d14614777aa7ca7de6d42fb1662 (patch) | |
tree | d7c24fb4d421f1cf165ed6a38e7d0a3443905636 | |
parent | 01ccfc375925a1643afbd5ce2eb8078a617db881 (diff) |
quick-read: implement qr_fstat.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
-rw-r--r-- | xlators/performance/quick-read/src/quick-read.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index a92c3473611..9043926e332 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -997,6 +997,99 @@ out: } +int32_t +qr_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, struct stat *buf) +{ + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +int32_t +qr_fstat_helper (call_frame_t *frame, xlator_t *this, fd_t *fd) +{ + STACK_WIND (frame, qr_fstat_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->fstat, fd); + return 0; +} + + +int32_t +qr_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) +{ + qr_fd_ctx_t *qr_fd_ctx = NULL; + char need_open = 0, can_wind = 0, need_unwind = 0; + uint64_t value = 0; + int32_t ret = -1, op_ret = -1, op_errno = -1; + call_stub_t *stub = NULL; + loc_t loc = {0, }; + char *path = NULL; + int flags = 0; + + ret = fd_ctx_get (fd, this, &value); + if (ret == 0) { + qr_fd_ctx = (qr_fd_ctx_t *)(long) value; + } + + if (qr_fd_ctx) { + LOCK (&qr_fd_ctx->lock); + { + path = qr_fd_ctx->path; + flags = qr_fd_ctx->flags; + + if (!(qr_fd_ctx->opened + || qr_fd_ctx->open_in_transit)) { + need_open = 1; + qr_fd_ctx->open_in_transit = 1; + } + + if (qr_fd_ctx->opened) { + can_wind = 1; + } else { + stub = fop_fstat_stub (frame, qr_fstat_helper, + fd); + if (stub == NULL) { + op_ret = -1; + op_errno = ENOMEM; + need_unwind = 1; + qr_fd_ctx->open_in_transit = 0; + goto unlock; + } + + list_add_tail (&stub->list, + &qr_fd_ctx->waiting_ops); + } + } + unlock: + UNLOCK (&qr_fd_ctx->lock); + } else { + can_wind = 1; + } + +out: + if (need_unwind) { + STACK_UNWIND (frame, op_ret, op_errno, NULL); + } else if (can_wind) { + STACK_WIND (frame, qr_fstat_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->fstat, fd); + } else if (need_open) { + op_ret = qr_loc_fill (&loc, fd->inode, path); + if (op_ret == -1) { + qr_resume_pending_ops (qr_fd_ctx); + goto out; + } + + STACK_WIND (frame, qr_open_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->open, &loc, flags, fd); + + qr_loc_wipe (&loc); + } + + return 0; +} + + int32_t init (xlator_t *this) { @@ -1073,6 +1166,7 @@ struct xlator_fops fops = { .open = qr_open, .readv = qr_readv, .writev = qr_writev, + .fstat = qr_fstat, }; |