summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--heal/src/glfs-heal.c39
-rw-r--r--libglusterfs/src/glusterfs.h2
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c2
-rw-r--r--xlators/cluster/ec/src/ec.c27
4 files changed, 54 insertions, 16 deletions
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
index 06dea1fff74..c014b826620 100644
--- a/heal/src/glfs-heal.c
+++ b/heal/src/glfs-heal.c
@@ -94,8 +94,18 @@ out:
}
static xlator_t*
-_get_afr_ancestor (xlator_t *xl)
+_get_ancestor (xlator_t *xl, gf_xl_afr_op_t heal_op)
{
+ static char *replica_xl[] = {"cluster/replicate", NULL};
+ static char *heal_xls[] = {"cluster/replicate", "cluster/disperse",
+ NULL};
+ char **ancestors = NULL;
+
+ if (heal_op == GF_SHD_OP_INDEX_SUMMARY)
+ ancestors = heal_xls;
+ else
+ ancestors = replica_xl;
+
if (!xl || !xl->parents)
return NULL;
@@ -103,7 +113,7 @@ _get_afr_ancestor (xlator_t *xl)
xl = xl->parents->xlator;
if (!xl)
break;
- if (strcmp (xl->type, "cluster/replicate") == 0)
+ if (gf_get_index_by_elem (ancestors, xl->type) != -1)
return xl;
}
@@ -234,8 +244,7 @@ glfsh_process_entries (xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
uuid_parse (entry->d_name, gfid);
uuid_copy (loc.gfid, gfid);
- ret = syncop_getxattr (this, &loc, &dict, GF_AFR_HEAL_INFO,
- NULL);
+ ret = syncop_getxattr (this, &loc, &dict, GF_HEAL_INFO, NULL);
if (ret)
continue;
@@ -434,9 +443,9 @@ out:
}
static int
-glfsh_validate_replicate_volume (xlator_t *xl)
+glfsh_validate_volume (xlator_t *xl, gf_xl_afr_op_t heal_op)
{
- xlator_t *afr_xl = NULL;
+ xlator_t *heal_xl = NULL;
int ret = -1;
while (xl->next)
@@ -444,8 +453,8 @@ glfsh_validate_replicate_volume (xlator_t *xl)
while (xl) {
if (strcmp (xl->type, "protocol/client") == 0) {
- afr_xl = _get_afr_ancestor (xl);
- if (afr_xl) {
+ heal_xl = _get_ancestor (xl, heal_op);
+ if (heal_xl) {
ret = 0;
break;
}
@@ -498,7 +507,7 @@ 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;
+ xlator_t *heal_xl = NULL;
xlator_t *old_THIS = NULL;
xl = top_subvol;
@@ -506,10 +515,10 @@ glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
xl = xl->next;
while (xl) {
if (strcmp (xl->type, "protocol/client") == 0) {
- afr_xl = _get_afr_ancestor (xl);
- if (afr_xl) {
+ heal_xl = _get_ancestor (xl, heal_op);
+ if (heal_xl) {
old_THIS = THIS;
- THIS = afr_xl;
+ THIS = heal_xl;
glfsh_print_pending_heals (fs, top_subvol,
rootloc, xl,
heal_op);
@@ -778,9 +787,11 @@ main (int argc, char **argv)
goto out;
}
- ret = glfsh_validate_replicate_volume (top_subvol);
+ ret = glfsh_validate_volume (top_subvol, heal_op);
if (ret < 0) {
- printf ("Volume %s is not of type replicate\n", volname);
+ printf ("Volume %s is not of type %s\n", volname,
+ (heal_op == GF_SHD_OP_INDEX_SUMMARY) ?
+ "replicate/disperse":"replicate");
goto out;
}
rootloc.inode = inode_ref (top_subvol->itable->root);
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index bcc9f57f99b..c5459018717 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -156,7 +156,7 @@
#define GF_XATTROP_INDEX_GFID "glusterfs.xattrop_index_gfid"
#define GF_XATTROP_INDEX_COUNT "glusterfs.xattrop_index_count"
-#define GF_AFR_HEAL_INFO "glusterfs.heal-info"
+#define GF_HEAL_INFO "glusterfs.heal-info"
#define GF_AFR_HEAL_SBRAIN "glusterfs.heal-sbrain"
#define GF_AFR_SBRAIN_STATUS "replica.split-brain-status"
#define GF_AFR_SBRAIN_CHOICE "replica.split-brain-choice"
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index afa40fbad2a..7fed62a5361 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1477,7 +1477,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
afr_marker_populate_args) == 0)
return 0;
- if (!strcmp (name, GF_AFR_HEAL_INFO)) {
+ if (!strcmp (name, GF_HEAL_INFO)) {
afr_get_heal_info (frame, this, loc, xdata);
return 0;
}
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 9b8251a5403..fd5123d61da 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -595,6 +595,30 @@ ec_marker_populate_args (call_frame_t *frame, int type, int *gauge,
}
int32_t
+ec_handle_heal_commands (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ const char *name, dict_t *xdata)
+{
+ dict_t *dict_rsp = NULL;
+ int op_ret = -1;
+ int op_errno = ENOMEM;
+
+ if (!name || strcmp (name, GF_HEAL_INFO))
+ return -1;
+
+ dict_rsp = dict_new ();
+ if (dict_rsp == NULL)
+ goto out;
+
+ if (dict_set_str (dict_rsp, "heal-info", "heal") == 0)
+ op_ret = 0;
+out:
+ STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict_rsp, NULL);
+ if (dict_rsp)
+ dict_unref (dict_rsp);
+ return 0;
+}
+
+int32_t
ec_gf_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
@@ -605,6 +629,9 @@ ec_gf_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
EC_INTERNAL_XATTR_OR_GOTO(name, NULL, error, out);
}
+ if (ec_handle_heal_commands (frame, this, loc, name, xdata) == 0)
+ return 0;
+
if (cluster_handle_marker_getxattr (frame, loc, name, ec->vol_uuid,
NULL, ec_marker_populate_args) == 0)
return 0;