summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2015-11-25 09:49:19 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-12-16 22:02:55 -0800
commit486b07dfc33782d27e3458659cdd6090f496ad35 (patch)
treec07068e0026591113344b57f24bf4e6dd79e6ed8 /xlators/cluster/afr
parent96da2fbc7fa7f9e27c645b98d8b12491be24a4c4 (diff)
glusterd/afr: store afr pending xattrs as a volume option
Backport of http://review.gluster.org/#/c/12738/ Problem: When AFR xlator initialises, it uses the name of the client xlators below it for storing the pending changelogs (xattrs). This can be problem when some other xlator is loaded in between AFR and the client. Though that is a trivial 'traverse-graph-till-the-client-and-use-the-name' fix in AFR's init(), there are other issues like when there's no client xlator at all when, say, AFR is moved to the server side. Fix: The client xlator names are currenly unique and stored as brickinfo->brick_ids. So persist these ids as comma separated values in AFR's volume_options and use them as xattr values during init(). Change-Id: Ie761ffeb3373a4c4d85ad05c84a768c4188aa90d BUG: 1291985 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/12977 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r--xlators/cluster/afr/src/afr.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 5ef920a13d1..4c072b6c69f 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -248,6 +248,8 @@ init (xlator_t *this)
int read_subvol_index = -1;
xlator_t *fav_child = NULL;
char *qtype = NULL;
+ char *xattrs_list = NULL;
+ char *ptr = NULL;
if (!this->children) {
gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -401,6 +403,7 @@ init (xlator_t *this)
goto out;
}
+ GF_OPTION_INIT ("afr-pending-xattr", xattrs_list, str, out);
priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key),
child_count,
gf_afr_mt_char);
@@ -408,20 +411,25 @@ init (xlator_t *this)
ret = -ENOMEM;
goto out;
}
-
- trav = this->children;
- i = 0;
- while (i < child_count) {
- priv->children[i] = trav->xlator;
-
+ ptr = gf_strdup (xattrs_list);
+ if (!ptr) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ for (i = 0, ptr = strtok (ptr, ","); ptr; ptr = strtok (NULL, ",")) {
ret = gf_asprintf (&priv->pending_key[i], "%s.%s",
- AFR_XATTR_PREFIX,
- trav->xlator->name);
- if (-1 == ret) {
+ AFR_XATTR_PREFIX, ptr);
+ if (ret == -1) {
ret = -ENOMEM;
goto out;
}
+ i++;
+ }
+ trav = this->children;
+ i = 0;
+ while (i < child_count) {
+ priv->children[i] = trav->xlator;
trav = trav->next;
i++;
}
@@ -457,6 +465,7 @@ init (xlator_t *this)
ret = 0;
out:
+ GF_FREE (ptr);
return ret;
}
@@ -780,6 +789,11 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_STR,
.default_value = AFR_DIRTY_DEFAULT,
},
+ { .key = {"afr-pending-xattr"},
+ .type = GF_OPTION_TYPE_STR,
+ .description = "Comma seperated list of xattrs that are used to "
+ "capture information on pending heals."
+ },
{ .key = {"metadata-splitbrain-forced-heal"},
.type = GF_OPTION_TYPE_BOOL,
.default_value = "off",