From ed9687b7fc050b6fcd8ef79eab977d1ef2f1e801 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Thu, 9 Jul 2009 00:27:57 +0000 Subject: quick-read: implement qr_fentrylk. Signed-off-by: Anand V. Avati --- xlators/performance/quick-read/src/quick-read.c | 100 ++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'xlators/performance/quick-read/src') diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 4b2e58ea014..ae2adaccd9d 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -1547,6 +1547,105 @@ qr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) } +int32_t +qr_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +int32_t +qr_fentrylk_helper (call_frame_t *frame, xlator_t *this, const char *volume, + fd_t *fd, const char *basename, entrylk_cmd cmd, + entrylk_type type) +{ + STACK_WIND(frame, qr_fentrylk_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fentrylk, volume, fd, basename, + cmd, type); + return 0; +} + + +int32_t +qr_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, + const char *basename, entrylk_cmd cmd, entrylk_type type) +{ + int flags = 0; + uint64_t value = 0; + call_stub_t *stub = NULL; + char *path = NULL; + loc_t loc = {0, }; + qr_fd_ctx_t *qr_fd_ctx = NULL; + int32_t ret = -1, op_ret = -1, op_errno = -1; + char need_open = 0, can_wind = 0, need_unwind = 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_fentrylk_stub (frame, + qr_fentrylk_helper, + volume, fd, basename, + cmd, type); + 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); + } else if (can_wind) { + STACK_WIND (frame, qr_fentrylk_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fentrylk, volume, fd, + basename, cmd, type); + } 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) { @@ -1629,6 +1728,7 @@ struct xlator_fops fops = { .fsetxattr = qr_fsetxattr, .fgetxattr = qr_fgetxattr, .flush = qr_flush, + .fentrylk = qr_fentrylk, }; -- cgit