diff options
author | Ravishankar N <ravishankar@redhat.com> | 2014-02-27 08:23:33 +0000 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-03-24 10:23:39 -0700 |
commit | a8b03479af1cd23baddd373a4d52f366b49c2398 (patch) | |
tree | f37dde7616d0ded30835e394365b409bd8114633 | |
parent | 17454dfea9f3c4d47fcf0b5370a6155f639c8aeb (diff) |
glusterd: op-version check for brickops.
cluster op-version must be atleast 4 for add/remove brick to proceed.
This change is required for the new afr-changelog xattr changes that
will be done for glusterFS 3.6 (http://review.gluster.org/#/c/7155/).
In add-brick, the check is done only when replica count is increased
because only that will affect the AFR xattrs.
In remove-brick, the check is unconditional failing which there will be
inconsistencies in the client xlator names amongst the volfiles of
different peers.
Change-Id: If981da2f33899aed585ab70bb11c09a093c9d8e6
BUG: 1066778
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/7122
Reviewed-by: Kaushal M <kaushal@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | libglusterfs/src/globals.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 31 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 21 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 3 |
4 files changed, 52 insertions, 4 deletions
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 16ab962686f..2e520c10e02 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -33,6 +33,7 @@ should keep changing with introduction of newer versions */ #define GD_OP_VERSION_4 4 /* Op-Version 4 */ +#define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_4 #include "xlator.h" diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index f15ec7b18e7..1804dd02e9a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -1207,6 +1207,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr) int ret = 0; char *volname = NULL; int count = 0; + int replica_count = 0; int i = 0; char *bricks = NULL; char *brick_list = NULL; @@ -1215,17 +1216,31 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr) char *brick = NULL; glusterd_brickinfo_t *brickinfo = NULL; glusterd_volinfo_t *volinfo = NULL; - glusterd_conf_t *priv = NULL; + xlator_t *this = NULL; char msg[2048] = {0,}; gf_boolean_t brick_alloc = _gf_false; char *all_bricks = NULL; char *str_ret = NULL; gf_boolean_t is_force = _gf_false; - priv = THIS->private; - if (!priv) - goto out; + this = THIS; + GF_ASSERT (this); + + ret = dict_get_int32 (dict, "replica-count", &replica_count); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Unable to get replica count"); + } + if (replica_count > 0) { + ret = op_version_check (this, GD_OP_VER_PERSISTENT_AFR_XATTRS, + msg, sizeof(msg)); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + } ret = dict_get_str (dict, "volname", &volname); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, @@ -1376,6 +1391,14 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) this = THIS; GF_ASSERT (this); + ret = op_version_check (this, GD_OP_VER_PERSISTENT_AFR_XATTRS, + msg, sizeof(msg)); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + goto out; + } + ret = dict_get_str (dict, "volname", &volname); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 0bec8c06ba8..fdfdcc28168 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -9042,6 +9042,27 @@ gd_update_volume_op_versions (glusterd_volinfo_t *volinfo) return; } +int +op_version_check (xlator_t *this, int min_op_version, char *msg, int msglen) +{ + int ret = 0; + glusterd_conf_t *priv = NULL; + + GF_ASSERT (this); + GF_ASSERT (msg); + + priv = this->private; + if (priv->op_version < min_op_version) { + snprintf (msg, msglen, "One or more nodes do not support " + "the required op-version. Cluster op-version must " + "atleast be %d.", min_op_version); + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + ret = -1; + } + return ret; +} + + /* A task is committed/completed once the task-id for it is cleared */ gf_boolean_t gd_is_remove_brick_committed (glusterd_volinfo_t *volinfo) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index aebf5fcef05..ec59d914336 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -582,6 +582,9 @@ glusterd_is_same_address (char *name1, char *name2); void gd_update_volume_op_versions (glusterd_volinfo_t *volinfo); +int +op_version_check (xlator_t *this, int min_op_version, char *msg, int msglen); + char* gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo); |