diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-open.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-open.c | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c index 43a38c0b112..00958438a4c 100644 --- a/xlators/cluster/afr/src/afr-open.c +++ b/xlators/cluster/afr/src/afr-open.c @@ -215,9 +215,8 @@ out: int -afr_up_down_flush_open_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, int32_t op_errno, - fd_t *fd) +afr_openfd_sh_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd) { afr_local_t *local = NULL; afr_private_t *priv = NULL; @@ -257,7 +256,7 @@ out: call_count = afr_frame_return (frame); if (call_count == 0) { - local->transaction.post_post_op (frame, this); + local->transaction.resume (frame, this); } return 0; @@ -265,7 +264,7 @@ out: static int -__unopened_count (int child_count, unsigned char *opened_on, unsigned char *child_up) +__unopened_count (int child_count, unsigned int *opened_on, unsigned char *child_up) { int i; int count = 0; @@ -280,7 +279,7 @@ __unopened_count (int child_count, unsigned char *opened_on, unsigned char *chil int -afr_up_down_flush_sh_unwind (call_frame_t *frame, xlator_t *this) +afr_openfd_sh_unwind (call_frame_t *frame, xlator_t *this) { afr_local_t *local = NULL; afr_private_t *priv = NULL; @@ -311,8 +310,17 @@ afr_up_down_flush_sh_unwind (call_frame_t *frame, xlator_t *this) fd_ctx = (afr_fd_ctx_t *)(long) ctx; - call_count = __unopened_count (priv->child_count, fd_ctx->opened_on, - local->child_up); + LOCK (&local->fd->lock); + { + call_count = __unopened_count (priv->child_count, + fd_ctx->opened_on, + local->child_up); + for (i = 0; i < priv->child_count; i++) { + fd_ctx->pre_op_done[i] = 0; + fd_ctx->pre_op_piggyback[i] = 0; + } + } + UNLOCK (&local->fd->lock); if (call_count == 0) { abandon = 1; @@ -332,7 +340,7 @@ afr_up_down_flush_sh_unwind (call_frame_t *frame, xlator_t *this) "opening fd for %s on subvolume %s", local->loc.path, priv->children[i]->name); - STACK_WIND_COOKIE (frame, afr_up_down_flush_open_cbk, + STACK_WIND_COOKIE (frame, afr_openfd_sh_open_cbk, (void *)(long) i, priv->children[i], priv->children[i]->fops->open, @@ -346,14 +354,14 @@ afr_up_down_flush_sh_unwind (call_frame_t *frame, xlator_t *this) out: if (abandon) - local->transaction.post_post_op (frame, this); + local->transaction.resume (frame, this); return 0; } int -afr_up_down_flush_post_post_op (call_frame_t *frame, xlator_t *this) +afr_openfd_sh (call_frame_t *frame, xlator_t *this) { afr_private_t *priv = NULL; afr_local_t *local = NULL; @@ -369,7 +377,7 @@ afr_up_down_flush_post_post_op (call_frame_t *frame, xlator_t *this) if (ret < 0) { gf_log (this->name, GF_LOG_TRACE, "Inode path failed. Possible open-unlink-write detected"); - afr_up_down_flush_sh_unwind (frame, this); + afr_openfd_sh_unwind (frame, this); return 0; } @@ -386,7 +394,7 @@ afr_up_down_flush_post_post_op (call_frame_t *frame, xlator_t *this) sh->need_data_self_heal = _gf_true; sh->mode = local->fd->inode->st_mode; sh->background = _gf_false; - sh->unwind = afr_up_down_flush_sh_unwind; + sh->unwind = afr_openfd_sh_unwind; afr_self_heal (frame, this); @@ -395,21 +403,7 @@ afr_up_down_flush_post_post_op (call_frame_t *frame, xlator_t *this) int -afr_up_down_flush_wind (call_frame_t *frame, xlator_t *this) -{ - afr_local_t *local = NULL; - afr_private_t *priv = NULL; - - local = frame->local; - priv = this->private; - - local->transaction.resume (frame, this); - return 0; -} - - -int -afr_up_down_flush_done (call_frame_t *frame, xlator_t *this) +afr_openfd_flush_done (call_frame_t *frame, xlator_t *this) { afr_private_t *priv = NULL; afr_local_t *local = NULL; @@ -418,7 +412,6 @@ afr_up_down_flush_done (call_frame_t *frame, xlator_t *this) afr_fd_ctx_t * fd_ctx = NULL; int _ret = -1; - int i = 0; priv = this->private; local = frame->local; @@ -435,26 +428,20 @@ afr_up_down_flush_done (call_frame_t *frame, xlator_t *this) fd_ctx->down_count = priv->down_count; fd_ctx->up_count = priv->up_count; - - for (i = 0; i < priv->child_count; i++) { - if (local->child_up[i]) - fd_ctx->pre_op_done[i] = 0; - } } out: UNLOCK (&local->fd->lock); afr_local_transaction_cleanup (local, this); - local->up_down_flush_cbk (frame, this); + local->openfd_flush_cbk (frame, this); return 0; } int -afr_up_down_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, - afr_flush_type type) +afr_openfd_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) { afr_private_t * priv = NULL; afr_local_t * local = NULL; @@ -473,18 +460,8 @@ afr_up_down_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, // local->fd = fd_ref (local->fd); - local->transaction.fop = afr_up_down_flush_wind; - local->transaction.done = afr_up_down_flush_done; - - switch (type) { - case AFR_CHILD_UP_FLUSH: - local->transaction.post_post_op = afr_up_down_flush_post_post_op; - break; - - case AFR_CHILD_DOWN_FLUSH: - local->transaction.post_post_op = NULL; - break; - } + local->transaction.fop = afr_openfd_sh; + local->transaction.done = afr_openfd_flush_done; local->transaction.start = 0; local->transaction.len = 0; @@ -493,7 +470,7 @@ afr_up_down_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, "doing up/down flush on fd=%p", fd); - afr_transaction (frame, this, AFR_FLUSH_TRANSACTION); + afr_transaction (frame, this, AFR_DATA_TRANSACTION); op_ret = 0; out: |