summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2019-11-26 17:03:44 +0530
committerMOHIT AGRAWAL <moagrawa@redhat.com>2019-12-05 08:37:24 +0000
commitdc757b2c97f5917885db76c62fa4fb429ae7b9ab (patch)
tree14b9f1b6cb7ced74360fd1dea50181dea4640615
parent6015ab7d8b37388e836f36a315af54f019839d91 (diff)
glusterd: set xaatrs after checking the brick order
Problem: When volume creation fails complaining about the bricks from same hosts for replica volumes, the bricks can't be re-used to create any volume without using force at the end. It says, brick is already part of a volume. Reason: When volume create opeartion issued, we set xattrs on the bricks. If the transaction fails in later checks, the xattrs will remain on the brick. When the brick is re-used, by looking at the xattrs, glusterd thinks it is already part of volume. Solution: Check the brick order for replica and disperse volumes before setting the xattrs. fixes: bz#1776801 Change-Id: I44a971b37f520e5a20dc9fad6520286d315063b9 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 24743b6..4d084e3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -1185,6 +1185,36 @@ glusterd_op_stage_create_volume(dict_t *dict, char **op_errstr,
}
}
+ /*Check brick order if the volume type is replicate or disperse. If
+ * force at the end of command not given then check brick order.
+ */
+ if (is_origin_glusterd(dict)) {
+ ret = dict_get_int32n(dict, "type", SLEN("type"), &type);
+ if (ret) {
+ snprintf(msg, sizeof(msg),
+ "Unable to get type of "
+ "volume %s",
+ volname);
+ gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, "%s",
+ msg);
+ goto out;
+ }
+
+ if (!is_force) {
+ if ((type == GF_CLUSTER_TYPE_REPLICATE) ||
+ (type == GF_CLUSTER_TYPE_DISPERSE)) {
+ ret = glusterd_check_brick_order(dict, msg);
+ if (ret) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BAD_BRKORDER,
+ "Not "
+ "creating volume because of "
+ "bad brick order");
+ goto out;
+ }
+ }
+ }
+ }
+
while (i < brick_count) {
i++;
brick = strtok_r(brick_list, " \n", &tmpptr);
@@ -1264,36 +1294,6 @@ glusterd_op_stage_create_volume(dict_t *dict, char **op_errstr,
brick_info = NULL;
}
- /*Check brick order if the volume type is replicate or disperse. If
- * force at the end of command not given then check brick order.
- */
- if (is_origin_glusterd(dict)) {
- ret = dict_get_int32n(dict, "type", SLEN("type"), &type);
- if (ret) {
- snprintf(msg, sizeof(msg),
- "Unable to get type of "
- "volume %s",
- volname);
- gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED, "%s",
- msg);
- goto out;
- }
-
- if (!is_force) {
- if ((type == GF_CLUSTER_TYPE_REPLICATE) ||
- (type == GF_CLUSTER_TYPE_DISPERSE)) {
- ret = glusterd_check_brick_order(dict, msg);
- if (ret) {
- gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BAD_BRKORDER,
- "Not "
- "creating volume because of "
- "bad brick order");
- goto out;
- }
- }
- }
- }
-
ret = dict_set_int32n(rsp_dict, "brick_count", SLEN("brick_count"),
local_brick_count);
if (ret) {