diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2011-09-30 07:07:59 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-09-29 22:43:11 -0700 |
commit | 5cfca9f388cd153bcbcb963ba91867acf3bfac25 (patch) | |
tree | 59b4eb5827643561a3786b07f4ad182cf3c501d0 /xlators/cluster/afr | |
parent | abb4cbeea35c40d69f18aba599f58d7e2dc5fdaf (diff) |
cluster/afr: set fd ctx on opendir
Change-Id: Ica845035781f47de990e9dcfefdeb37bed99d515
BUG: 3637
Reviewed-on: http://review.gluster.com/536
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 34 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-dir-read.c | 31 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-open.c | 30 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 3 |
4 files changed, 59 insertions, 39 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 0131feaa075..afff0517e7f 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -3813,3 +3813,37 @@ afr_set_low_priority (call_frame_t *frame) { frame->root->pid = LOW_PRIO_PROC_PID; } + +int +afr_child_fd_ctx_set (xlator_t *this, fd_t *fd, int32_t child, + int flags, int32_t wbflags) +{ + int ret = 0; + uint64_t ctx = 0; + afr_fd_ctx_t *fd_ctx = NULL; + + GF_ASSERT (fd && fd->inode); + ret = afr_fd_ctx_set (this, fd); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, + "could not set fd ctx for fd=%p", fd); + goto out; + } + + ret = fd_ctx_get (fd, this, &ctx); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, + "could not get fd ctx for fd=%p", fd); + goto out; + } + + fd_ctx = (afr_fd_ctx_t *)(long) ctx; + fd_ctx->opened_on[child] = AFR_FD_OPENED; + if (!IA_ISDIR (fd->inode->ia_type)) { + fd_ctx->flags = flags; + fd_ctx->wbflags = wbflags; + } + ret = 0; +out: + return ret; +} diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c index 57f0a03fa6a..f2e6760cfd7 100644 --- a/xlators/cluster/afr/src/afr-dir-read.c +++ b/xlators/cluster/afr/src/afr-dir-read.c @@ -229,20 +229,31 @@ afr_opendir_cbk (call_frame_t *frame, void *cookie, int32_t up_children_count = 0; int ret = -1; int call_count = -1; + int32_t child_index = 0; priv = this->private; local = frame->local; + child_index = (long) cookie; up_children_count = afr_up_children_count (local->child_up, priv->child_count); LOCK (&frame->lock); { - if (op_ret >= 0) + if (op_ret >= 0) { local->op_ret = op_ret; + ret = afr_child_fd_ctx_set (this, fd, child_index, + 0, 0); + if (ret) { + local->op_ret = -1; + local->op_errno = -ret; + goto unlock; + } + } local->op_errno = op_errno; } +unlock: UNLOCK (&frame->lock); call_count = afr_frame_return (frame); @@ -251,15 +262,6 @@ afr_opendir_cbk (call_frame_t *frame, void *cookie, if (local->op_ret != 0) goto out; - ret = afr_fd_ctx_set (this, local->fd); - if (ret) { - local->op_ret = -1; - local->op_errno = -1; - gf_log (this->name, GF_LOG_ERROR, - "failed to set fd ctx for fd %p", - local->fd); - goto out; - } if (!afr_is_opendir_done (this, local->fd->inode) && up_children_count > 1) { @@ -332,10 +334,11 @@ afr_opendir (call_frame_t *frame, xlator_t *this, for (i = 0; i < child_count; i++) { if (local->child_up[i]) { - STACK_WIND (frame, afr_opendir_cbk, - priv->children[i], - priv->children[i]->fops->opendir, - loc, fd); + STACK_WIND_COOKIE (frame, afr_opendir_cbk, + (void*) (long) i, + priv->children[i], + priv->children[i]->fops->opendir, + loc, fd); if (!--call_count) break; diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c index 4075c272408..646d23ccb53 100644 --- a/xlators/cluster/afr/src/afr-open.c +++ b/xlators/cluster/afr/src/afr-open.c @@ -143,8 +143,6 @@ afr_open_cbk (call_frame_t *frame, void *cookie, fd_t *fd) { afr_local_t * local = NULL; - uint64_t ctx = 0; - afr_fd_ctx_t *fd_ctx = NULL; int ret = 0; int call_count = -1; int child_index = (long) cookie; @@ -163,32 +161,14 @@ afr_open_cbk (call_frame_t *frame, void *cookie, local->op_ret = op_ret; local->success_count++; - ret = afr_fd_ctx_set (this, fd); - - if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "could not set fd ctx for fd=%p", fd); - - local->op_ret = -1; - local->op_errno = -ret; - goto unlock; - } - - ret = fd_ctx_get (fd, this, &ctx); - - if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "could not get fd ctx for fd=%p", fd); - local->op_ret = -1; + ret = afr_child_fd_ctx_set (this, fd, child_index, + local->cont.open.flags, + local->cont.open.wbflags); + if (ret) { + local->op_ret = -1; local->op_errno = -ret; goto unlock; } - - fd_ctx = (afr_fd_ctx_t *)(long) ctx; - - fd_ctx->opened_on[child_index] = AFR_FD_OPENED; - fd_ctx->flags = local->cont.open.flags; - fd_ctx->wbflags = local->cont.open.wbflags; } } unlock: diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index 0f4db7d91f1..7320c8d7cf3 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -1027,4 +1027,7 @@ afr_data_self_heal_enabled (char *data_self_heal); void afr_set_low_priority (call_frame_t *frame); +int +afr_child_fd_ctx_set (xlator_t *this, fd_t *fd, int32_t child, + int flags, int32_t wb_flags); #endif /* __AFR_H__ */ |