summaryrefslogtreecommitdiffstats
path: root/heal/src
diff options
context:
space:
mode:
authorAnuradha <atalur@redhat.com>2015-01-23 10:51:11 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-01-30 08:28:16 -0800
commit64132200590a9310ea221524e13db8a09bd89313 (patch)
treeb5618b1583807ac2e3871eaf81662101686a6727 /heal/src
parent0f84f8e8048367737a2dd6ddf0c57403e757441d (diff)
afr : Change in heal info split-brain command
Implementation of heal info split-brain command with glfs-heal. Change-Id: I233eb790de6eb5468a4cbb12a1cef0f97db2a1d2 BUG: 1183019 Signed-off-by: Anuradha <atalur@redhat.com> Reviewed-on: http://review.gluster.org/9459 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'heal/src')
-rw-r--r--heal/src/glfs-heal.c79
1 files changed, 66 insertions, 13 deletions
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
index f49f3a5..a6208fa 100644
--- a/heal/src/glfs-heal.c
+++ b/heal/src/glfs-heal.c
@@ -21,7 +21,10 @@
#define DEFAULT_HEAL_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs"
#define USAGE_STR "Usage: %s <VOLNAME> [bigger-file <FILE> | "\
- "source-brick <HOSTNAME:BRICKNAME> [<FILE>]]\n"
+ "source-brick <HOSTNAME:BRICKNAME> [<FILE>] | "\
+ "split-brain-info]\n"
+
+typedef void (*print_status) (dict_t *, char *, uuid_t, uint64_t *);
int glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol,
loc_t *rootloc, char *file, dict_t *xattr_req);
@@ -190,6 +193,25 @@ out:
}
void
+glfsh_print_spb_status (dict_t *dict, char *path, uuid_t gfid,
+ uint64_t *num_entries)
+{
+ char *value = NULL;
+ int ret = 0;
+
+ ret = dict_get_str (dict, "heal-info", &value);
+ if (ret)
+ return;
+
+ if (!strcmp (value, "split-brain")) {
+ (*num_entries)++;
+ printf ("%s\n",
+ path ? path : uuid_utoa (gfid));
+ }
+ return;
+}
+
+void
glfsh_print_heal_status (dict_t *dict, char *path, uuid_t gfid,
uint64_t *num_entries)
{
@@ -250,7 +272,8 @@ glfsh_heal_entries (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
static int
glfsh_process_entries (xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
- uint64_t *offset, uint64_t *num_entries)
+ uint64_t *offset, uint64_t *num_entries,
+ print_status glfsh_print_status)
{
gf_dirent_t *entry = NULL;
gf_dirent_t *tmp = NULL;
@@ -291,8 +314,8 @@ glfsh_process_entries (xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
continue;
}
if (dict)
- glfsh_print_heal_status (dict, path, gfid,
- num_entries);
+ glfsh_print_status (dict, path, gfid,
+ num_entries);
}
ret = 0;
GF_FREE (path);
@@ -331,8 +354,17 @@ glfsh_crawl_directory (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
goto out;
if (heal_op == GF_AFR_OP_INDEX_SUMMARY) {
- ret = glfsh_process_entries (readdir_xl, fd, &entries,
- &offset, &num_entries);
+ ret = glfsh_process_entries (readdir_xl, fd,
+ &entries, &offset,
+ &num_entries,
+ glfsh_print_heal_status);
+ if (ret < 0)
+ goto out;
+ } else if (heal_op == GF_AFR_OP_SPLIT_BRAIN_FILES) {
+ ret = glfsh_process_entries (readdir_xl, fd,
+ &entries, &offset,
+ &num_entries,
+ glfsh_print_spb_status);
if (ret < 0)
goto out;
} else if (heal_op == GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK) {
@@ -353,6 +385,9 @@ out:
} else {
if (heal_op == GF_AFR_OP_INDEX_SUMMARY)
printf ("Number of entries: %"PRIu64"\n", num_entries);
+ else if (heal_op == GF_AFR_OP_SPLIT_BRAIN_FILES)
+ printf ("Number of entries in split-brain: %"PRIu64"\n"
+ , num_entries);
else if (heal_op == GF_AFR_OP_SBRAIN_HEAL_FROM_BRICK)
printf ("Number of healed entries: %"PRIu64"\n",
num_entries);
@@ -412,7 +447,7 @@ out:
void
glfsh_print_pending_heals (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
- xlator_t *xl)
+ xlator_t *xl, gf_xl_afr_op_t heal_op)
{
int ret = 0;
loc_t dirloc = {0};
@@ -424,7 +459,7 @@ glfsh_print_pending_heals (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
if (!xattr_req)
goto out;
- ret = dict_set_int32 (xattr_req, "heal-op", GF_AFR_OP_INDEX_SUMMARY);
+ ret = dict_set_int32 (xattr_req, "heal-op", heal_op);
if (ret)
goto out;
ret = glfsh_print_brick (xl, rootloc);
@@ -453,8 +488,13 @@ glfsh_print_pending_heals (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
fd_unref (fd);
if (xattr_req)
dict_unref (xattr_req);
- if (ret < 0)
- printf ("Failed to find entries with pending self-heal\n");
+ if (ret < 0) {
+ if (heal_op == GF_AFR_OP_INDEX_SUMMARY)
+ printf ("Failed to find entries with pending"
+ " self-heal\n");
+ if (heal_op == GF_AFR_OP_SPLIT_BRAIN_FILES)
+ printf ("Failed to find entries in split-brain\n");
+ }
out:
loc_wipe (&dirloc);
return;
@@ -521,7 +561,8 @@ out:
int
-glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc)
+glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
+ gf_xl_afr_op_t heal_op)
{
xlator_t *xl = NULL;
xlator_t *afr_xl = NULL;
@@ -537,7 +578,8 @@ glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc)
old_THIS = THIS;
THIS = afr_xl;
glfsh_print_pending_heals (fs, top_subvol,
- rootloc, xl);
+ rootloc, xl,
+ heal_op);
THIS = old_THIS;
printf ("\n");
}
@@ -711,6 +753,15 @@ main (int argc, char **argv)
case 2:
heal_op = GF_AFR_OP_INDEX_SUMMARY;
break;
+ case 3:
+ if (!strcmp (argv[2], "split-brain-info")) {
+ heal_op = GF_AFR_OP_SPLIT_BRAIN_FILES;
+ } else {
+ printf (USAGE_STR, argv[0]);
+ ret = -1;
+ goto out;
+ }
+ break;
case 4:
if (!strcmp (argv[2], "bigger-file")) {
heal_op = GF_AFR_OP_SBRAIN_HEAL_FROM_BIGGER_FILE;
@@ -799,7 +850,9 @@ main (int argc, char **argv)
switch (heal_op) {
case GF_AFR_OP_INDEX_SUMMARY:
- ret = glfsh_gather_heal_info (fs, top_subvol, &rootloc);
+ case GF_AFR_OP_SPLIT_BRAIN_FILES:
+ ret = glfsh_gather_heal_info (fs, top_subvol, &rootloc,
+ heal_op);
break;
case GF_AFR_OP_SBRAIN_HEAL_FROM_BIGGER_FILE:
ret = glfsh_heal_from_bigger_file (fs, top_subvol,