diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2013-12-10 12:51:37 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-04-28 09:38:57 -0700 |
commit | b744a9cf93171cbe6c6f43c6f241888754e27fa7 (patch) | |
tree | 3978bf56c004588cdbbdc29978166a712e32d2fd | |
parent | ba8212527e886a94b8d393172e0672c44de8457b (diff) |
cluster/afr: Add dry-run functionality to self-heal.
This will be useful in figuring out if a file needs
self-heal or not with certainity for data-self-heal
Change-Id: Idf98a68e69f2c35646ef2e7c97302586fe1dc07d
BUG: 1039544
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/6510
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 21 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 4 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 5 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 7 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-metadata.c | 4 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 6 |
6 files changed, 40 insertions, 7 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 66978a910aa..953df5a67a4 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -1743,14 +1743,23 @@ afr_self_heal_lookup_unwind (call_frame_t *frame, xlator_t *this, afr_lookup_done_success_action (frame, this, _gf_true); xattr = local->cont.lookup.xattr; - if (xattr) { + if (!xattr) + goto out; + + if (sh_failed) { ret = dict_set_int32 (xattr, "sh-failed", sh_failed); if (ret) gf_log (this->name, GF_LOG_ERROR, "%s: Failed to set " "sh-failed to %d", local->loc.path, sh_failed); - - if (local->self_heal.actual_sh_started == _gf_true && - sh_failed == 0) { + } else { + ret = dict_set_int32 (xattr, "metadata-self-heal-pending", + local->self_heal.metadata_sh_pending); + ret = dict_set_int32 (xattr, "data-self-heal-pending", + local->self_heal.data_sh_pending); + ret = dict_set_int32 (xattr, "entry-self-heal-pending", + local->self_heal.entry_sh_pending); + + if (local->self_heal.actual_sh_started == _gf_true) { ret = dict_set_int32 (xattr, "actual-sh-done", 1); if (ret) gf_log(this->name, GF_LOG_ERROR, "%s: Failed to" @@ -2511,6 +2520,10 @@ afr_lookup (call_frame_t *frame, xlator_t *this, &local->foreground_self_heal); dict_del (xattr_req, "foreground-self-heal"); + ret = dict_get_int32 (xattr_req, "dry-run-self-heal", + &local->self_heal.dry_run); + dict_del (xattr_req, "dry-run-self-heal"); + ret = afr_lookup_xattr_req_prepare (local, this, xattr_req, &local->loc, &gfid_req); if (ret) { diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index df537086e62..6f82761b33d 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -2260,6 +2260,7 @@ afr_self_heal_local_init (afr_local_t *l, xlator_t *this) shc->unwind = sh->unwind; shc->gfid_sh_success_cbk = sh->gfid_sh_success_cbk; + shc->dry_run = sh->dry_run; shc->do_missing_entry_self_heal = sh->do_missing_entry_self_heal; shc->do_gfid_self_heal = sh->do_gfid_self_heal; shc->do_data_self_heal = sh->do_data_self_heal; @@ -2352,6 +2353,9 @@ afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this) orig_frame_local = sh->orig_frame->local; orig_frame_sh = &orig_frame_local->self_heal; orig_frame_sh->actual_sh_started = _gf_true; + orig_frame_sh->entry_sh_pending = sh->entry_sh_pending; + orig_frame_sh->data_sh_pending = sh->data_sh_pending; + orig_frame_sh->metadata_sh_pending = sh->metadata_sh_pending; sh->unwind (sh->orig_frame, this, sh->op_ret, sh->op_errno, is_self_heal_failed (sh, AFR_CHECK_ALL)); } diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 9de26ee569c..e5ca84292fa 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -1042,6 +1042,7 @@ afr_sh_data_fxattrop_fstat_done (call_frame_t *frame, xlator_t *this) afr_sh_data_setattr (frame, this, &sh->buf[tstamp_source]); } else { afr_set_data_sh_info_str (local, sh, this); + if (nsources == 0) { gf_log (this->name, GF_LOG_DEBUG, "No self-heal needed for %s", @@ -1051,7 +1052,9 @@ afr_sh_data_fxattrop_fstat_done (call_frame_t *frame, xlator_t *this) return 0; } - if (sh->do_data_self_heal && + sh->data_sh_pending = _gf_true; + + if (!sh->dry_run && sh->do_data_self_heal && afr_data_self_heal_enabled (priv->data_self_heal)) afr_sh_data_fix (frame, this); else diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 0ca06aaa382..8359079cea4 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -2343,7 +2343,12 @@ afr_sh_entry_fix (call_frame_t *frame, xlator_t *this, sh->fresh_children); heal: - afr_sh_entry_sync_prepare (frame, this); + sh->entry_sh_pending = _gf_true; + if (sh->dry_run) { + afr_sh_entry_finish (frame, this); + } else { + afr_sh_entry_sync_prepare (frame, this); + } out: return; } diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c index fd5da6cfd33..e26d3580e51 100644 --- a/xlators/cluster/afr/src/afr-self-heal-metadata.c +++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c @@ -672,7 +672,9 @@ afr_sh_metadata_fix (call_frame_t *frame, xlator_t *this, sh->fresh_children); } - if (sh->do_metadata_self_heal && priv->metadata_self_heal) + sh->metadata_sh_pending = _gf_true; + if (!sh->dry_run && + sh->do_metadata_self_heal && priv->metadata_self_heal) afr_sh_metadata_sync_prepare (frame, this); else afr_sh_metadata_finish (frame, this); diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index dc0bc06fb70..676bd9b9466 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -285,6 +285,12 @@ struct afr_self_heal_ { gf_boolean_t entries_skipped; gf_boolean_t actual_sh_started; + + int32_t dry_run; + gf_boolean_t metadata_sh_pending; + gf_boolean_t data_sh_pending; + gf_boolean_t entry_sh_pending; + gf_boolean_t sync_done; gf_boolean_t data_lock_held; gf_boolean_t sh_dom_lock_held; |