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 | |
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>
-rw-r--r-- | libglusterfs/src/globals.h | 2 | ||||
-rwxr-xr-x | tests/bugs/glusterfs/bug-853690.t | 1 | ||||
-rwxr-xr-x | tests/bugs/glusterfs/bug-892730.t | 1 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 94 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 2 |
5 files changed, 66 insertions, 34 deletions
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index f6fc8de16de..25bd8dd2737 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -68,6 +68,8 @@ #define GD_OP_VERSION_3_8_0 30800 /* Op-version for GlusterFS 3.8.0 */ +#define GD_OP_VERSION_3_9_0 30900 /* Op-version for GlusterFS 3.9.0 */ + #define GD_OP_VERSION_4_0_0 40000 /* Op-version for GlusterFS 4.0.0 */ #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 diff --git a/tests/bugs/glusterfs/bug-853690.t b/tests/bugs/glusterfs/bug-853690.t index 7880b64488f..59facfcddb0 100755 --- a/tests/bugs/glusterfs/bug-853690.t +++ b/tests/bugs/glusterfs/bug-853690.t @@ -53,7 +53,6 @@ end-volume volume test-replicate-0 type cluster/replicate - option afr-pending-xattr test-locks-0,test-locks-1 option background-self-heal-count 0 subvolumes test-locks-0 test-locks-1 end-volume diff --git a/tests/bugs/glusterfs/bug-892730.t b/tests/bugs/glusterfs/bug-892730.t index 1fa0ff3bfb4..a76961134c5 100755 --- a/tests/bugs/glusterfs/bug-892730.t +++ b/tests/bugs/glusterfs/bug-892730.t @@ -53,7 +53,6 @@ end-volume volume test-replicate-0 type cluster/replicate - option afr-pending-xattr test-locks-0,test-locks-1 option background-self-heal-count 0 subvolumes test-locks-0 test-locks-1 end-volume 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*/ |