diff options
author | Ravishankar N <ravishankar@redhat.com> | 2016-06-03 18:22:22 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-06-09 01:20:43 -0700 |
commit | 51e1028373b4a4082a771001b813d6f19aeacb37 (patch) | |
tree | 7e4860bbc69f8b371c641c64fc7ac0b26bff37d4 /xlators | |
parent | ea4d4175ab3fc5cc1545ebde4d8d35ba0bf4aa3f (diff) |
afr: afr-pending-xattr fallback check
Commit 6e635284a4411b816d4d860a28262c9e6dc4bd6a introduced a comma
separated list of values to be used as AFR's pending changelogs. If
this xlator option is missing in the volfile, fall back to using client
xlator names for constructing the pending changelog names.
Also, since the aforementioned commit was reverted from 3.7 and 3.8
branches, introduce GD_OP_VERSION_3_9_0 and change the op-version for this
feature to GD_OP_VERSION_3_9_0.
Change-Id: I3639b9ab475bd8d9929cc7527d9f4584dee1ad1b
BUG: 1285152
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/14642
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 94 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 2 |
2 files changed, 64 insertions, 32 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index 15e4ec41891..da62564e93a 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -274,6 +274,67 @@ static const char *favorite_child_warning_str = "You have specified subvolume '% "WILL BE LOST."; +static int +afr_pending_xattrs_init (afr_private_t *priv, xlator_t *this) +{ + int ret = -1; + int i = 0; + char *ptr = NULL; + char *ptr1 = NULL; + char *xattrs_list = NULL; + xlator_list_t *trav = NULL; + + trav = this->children; + + GF_OPTION_INIT ("afr-pending-xattr", xattrs_list, str, out); + priv->pending_key = GF_CALLOC (sizeof (*priv->pending_key), + priv->child_count, gf_afr_mt_char); + if (!priv->pending_key) { + ret = -ENOMEM; + goto out; + } + if (!xattrs_list) { + gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_NO_CHANGELOG, + "Unable to fetch afr-pending-xattr option from volfile." + " Falling back to using client translator names. "); + + while (i < priv->child_count) { + ret = gf_asprintf (&priv->pending_key[i], "%s.%s", + AFR_XATTR_PREFIX, + trav->xlator->name); + if (ret == -1) { + ret = -ENOMEM; + goto out; + } + trav = trav->next; + i++; + } + ret = 0; + goto out; + } + + ptr = ptr1 = 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, ptr); + if (ret == -1) { + ret = -ENOMEM; + goto out; + } + i++; + } + ret = 0; + +out: + GF_FREE (ptr1); + return ret; + +} + int32_t init (xlator_t *this) { @@ -287,8 +348,6 @@ init (xlator_t *this) int read_subvol_index = -1; xlator_t *fav_child = NULL; char *qtype = NULL; - char *xattrs_list = NULL; - char *ptr = NULL; char *fav_child_policy = NULL; if (!this->children) { @@ -466,35 +525,9 @@ 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); - if (!priv->pending_key) { - ret = -ENOMEM; - goto out; - } - if (!xattrs_list) { - ret = -EINVAL; - gf_msg (this->name, GF_LOG_ERROR, -ret, AFR_MSG_NO_CHANGELOG, - "Unable to fetch afr pending changelogs. Is op-version" - " >= 30707?"); + ret = afr_pending_xattrs_init (priv, this); + if (ret) goto out; - } - 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, ptr); - if (ret == -1) { - ret = -ENOMEM; - goto out; - } - i++; - } trav = this->children; i = 0; @@ -535,7 +568,6 @@ init (xlator_t *this) ret = 0; out: - GF_FREE (ptr); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 52bb75fd664..a56de2dd858 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3490,7 +3490,7 @@ set_afr_pending_xattrs_option (volgen_graph_t *graph, conf = this->private; GF_VALIDATE_OR_GOTO (this->name, conf, out); - if (conf->op_version < GD_OP_VERSION_3_7_7) + if (conf->op_version < GD_OP_VERSION_3_9_0) return ret; /* (brick_id x rep.count) + (rep.count-1 commas) + NULL*/ |