diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-metadata.c')
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-metadata.c | 93 | 
1 files changed, 21 insertions, 72 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c index 03b91dae300..af2f76d94f9 100644 --- a/xlators/cluster/afr/src/afr-self-heal-metadata.c +++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c @@ -461,8 +461,9 @@ afr_sh_metadata_sync_prepare (call_frame_t *frame, xlator_t *this)  } -int -afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this) +void +afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this, +                     int32_t op_ret, int32_t op_errno)  {          afr_local_t     *local = NULL;          afr_self_heal_t *sh = NULL; @@ -475,23 +476,23 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)          sh = &local->self_heal;          priv = this->private; -        afr_build_pending_matrix (priv->pending_key, sh->pending_matrix, -                                  sh->xattr, AFR_METADATA_TRANSACTION, -                                  priv->child_count); - -        afr_sh_print_pending_matrix (sh->pending_matrix, this); - -        nsources = afr_mark_sources (sh->sources, sh->pending_matrix, sh->buf, -                                     priv->child_count, AFR_SELF_HEAL_METADATA, -                                     sh->child_success, this->name); - +        if (op_ret < 0) { +                sh->op_failed = 1; +                afr_sh_set_error (sh, op_errno); +                afr_sh_metadata_finish (frame, this); +                goto out; +        } +        nsources = afr_build_sources (this, sh->xattr, sh->buf, +                                      sh->pending_matrix, sh->sources, +                                      sh->child_success, +                                      AFR_METADATA_TRANSACTION);          if (nsources == 0) {                  gf_log (this->name, GF_LOG_TRACE,                          "No self-heal needed for %s",                          local->loc.path);                  afr_sh_metadata_finish (frame, this); -                return 0; +                goto out;          }          if ((nsources == -1) @@ -518,7 +519,7 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)                  local->govinda_gOvinda = 1;                  afr_sh_metadata_finish (frame, this); -                return 0; +                goto out;          }          source = afr_sh_select_source (sh->sources, priv->child_count); @@ -528,7 +529,7 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)                          "No active sources found.");                  afr_sh_metadata_finish (frame, this); -                return 0; +                goto out;          }          sh->source = source; @@ -546,62 +547,8 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this)          }          afr_sh_metadata_sync_prepare (frame, this); - -        return 0; -} - - -int -afr_sh_metadata_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, -                            int32_t op_ret, int32_t op_errno, -                            inode_t *inode, struct iatt *buf, dict_t *xattr, -                            struct iatt *postparent) -{ -        afr_local_t     *local = NULL; -        afr_self_heal_t *sh = NULL; -        afr_private_t   *priv = NULL; -        int              call_count = 0; -        int              child_index = 0; - - -        local = frame->local; -        sh = &local->self_heal; -        priv = this->private; - -        child_index = (long) cookie; - -        LOCK (&frame->lock); -        { -                if (op_ret == 0) { -                        gf_log (this->name, GF_LOG_TRACE, -                                "path %s on subvolume %s is of mode 0%o", -                                local->loc.path, -                                priv->children[child_index]->name, -                                buf->ia_type); - -                        sh->buf[child_index] = *buf; -                        if (xattr) -                                sh->xattr[child_index] = dict_ref (xattr); -                        sh->child_success[sh->success_count] = child_index; -                        sh->success_count++; -                } else { -                        gf_log (this->name, GF_LOG_INFO, -                                "path %s on subvolume %s => -1 (%s)", -                                local->loc.path, -                                priv->children[child_index]->name, -                                strerror (op_errno)); - -                        sh->child_errno[child_index] = op_errno; -                } -        } -        UNLOCK (&frame->lock); - -        call_count = afr_frame_return (frame); - -        if (call_count == 0) -                afr_sh_metadata_fix (frame, this); - -        return 0; +out: +        return;  }  int @@ -626,7 +573,9 @@ afr_sh_metadata_post_nonblocking_inodelk_cbk (call_frame_t *frame,                          "inodelks done for %s. Proceeding to FOP",                          local->loc.path);                  afr_sh_common_lookup (frame, this, &local->loc, -                                      afr_sh_metadata_lookup_cbk, _gf_false); +                                      afr_sh_metadata_fix, NULL, +                                      AFR_LOOKUP_FAIL_CONFLICTS | +                                      AFR_LOOKUP_FAIL_MISSING_GFIDS);          }          return 0;  | 
