diff options
author | Ravishankar N <ravishankar@redhat.com> | 2015-01-09 14:43:22 +0000 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-01-15 01:28:37 -0800 |
commit | 8beaf169e39b262416e2274a028292379d39b310 (patch) | |
tree | e5cfd6da9af293ba7625c057914583a03bbeadab /xlators/cluster/afr/src/afr-common.c | |
parent | 6da85222e5e49bcb15c4c8998f26c8dffb6a5b34 (diff) |
cluster/afr: split-brain resolution CLI
Extend the AFR heal command to include automated split-brain resolution.
This patch [3/3] is the final patch for afr automated split-brain resolution
implementation.
"gluster volume heal <VOLNAME> [full | statistics [heal-count [replica
<HOSTNAME:BRICKNAME>]] |info [healed | heal-failed | split-brain]| split-brain
{bigger-file <FILE> |source-brick <HOSTNAME:BRICKNAME> [<FILE>]}]"
The new additions being:
1.gluster volume heal <VOLNAME> split-brain bigger-file <FILE>
Locates the replica containing the FILE, selects bigger-file as source and
completes heal.
2.gluster volume heal <VOLNAME> split-brain source-brick <HOSTNAME:BRICKNAME>
<FILE>
Selects <FILE> present in <HOSTNAME:BRICKNAME> as source and completes heal.
3.gluster volume heal <VOLNAME> split-brain <HOSTNAME:BRICKNAME>
Selects all split-brained files in <HOSTNAME:BRICKNAME> as source and completes
heal.
Note: <FILE> can be either the full file name as seen from the root of the
volume (or) the gfid-string representation of the file, which sometimes gets
displayed in the heal info command's output.
Entry/gfid split-brain resolution is not supported.
Example can be found in the test case.
Change-Id: I4649733922d406f14f28ee9033a5cb627b9538b3
BUG: 1136769
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/9377
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-common.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index f39db802588..e6d45add4e8 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -4471,5 +4471,81 @@ out: AFR_STACK_UNWIND (getxattr, frame, ret, op_errno, dict, NULL); if (dict) dict_unref (dict); + if (inode) { + inode_forget (inode, 1); + inode_unref (inode); + } + return ret; +} + +int32_t +afr_heal_splitbrain_file(call_frame_t *frame, xlator_t *this, loc_t *loc) +{ + gf_boolean_t data_selfheal = _gf_false; + gf_boolean_t metadata_selfheal = _gf_false; + gf_boolean_t entry_selfheal = _gf_false; + dict_t *dict = NULL; + afr_local_t *local = NULL; + inode_t *inode = NULL; + int entry_ret = 0, metadata_ret = 0, data_ret = 0; + int ret = 0, op_errno = 0; + + local = frame->local; + dict = dict_new (); + if (!dict) { + op_errno = ENOMEM; + ret = -1; + goto out; + } + + ret = afr_selfheal_unlocked_inspect (frame, this, loc->gfid, &inode, + &data_selfheal, + &metadata_selfheal, + &entry_selfheal); + if (ret) { + op_errno = -ret; + ret = -1; + goto out; + } + + if (!data_selfheal && !metadata_selfheal && !entry_selfheal) { + ret = dict_set_str (dict, "sh-fail-msg", + "File not in split-brain"); + if (ret) + gf_log (this->name, GF_LOG_WARNING, + "Failed to set sh-fail-msg in dict"); + ret = 0; + goto out; + } + + if (data_selfheal) + data_ret = afr_selfheal_data (frame, this, inode); + + if (metadata_selfheal) + metadata_ret = afr_selfheal_metadata (frame, this, inode); + + if (entry_selfheal) + entry_ret = afr_selfheal_entry (frame, this, inode); + + ret = (data_ret | metadata_ret | entry_ret); + + if (local->xdata_rsp) { + /* 'sh-fail-msg' has been set in the dict during self-heal.*/ + dict_copy (local->xdata_rsp, dict); + ret = 0; + } else if (ret) { + /*Some other error during self-heal. Just propagate it.*/ + op_errno = -ret; + ret = -1; + } + +out: + AFR_STACK_UNWIND (getxattr, frame, ret, op_errno, dict, NULL); + if (dict) + dict_unref(dict); + if (inode) { + inode_forget (inode, 1); + inode_unref (inode); + } return ret; } |