From 2fad4eb4efb13d5bf79b4425afa9ce3f87c13e85 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Sat, 17 Nov 2012 11:59:39 +0530 Subject: glusterd: brick path availability check only for local bricks Change-Id: Ica50fb92608f5fd75f8887e0718177faf29d31c4 BUG: 877522 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.org/4203 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-utils.c | 68 ++++++++++++++++++------------ 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 8dc83d5e..28b9cdc7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -4375,41 +4375,53 @@ glusterd_new_brick_validate (char *brick, glusterd_brickinfo_t *brickinfo, ret = glusterd_resolve_brick (newbrickinfo); if (ret) { - snprintf (op_errstr, len, "Host %s not a friend", - newbrickinfo->hostname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", op_errstr); + snprintf(op_errstr, len, "Host %s is not in \'Peer " + "in Cluster\' state", newbrickinfo->hostname); + gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); goto out; } - if (!uuid_compare (MY_UUID, newbrickinfo->uuid)) - goto brick_validation; - ret = glusterd_friend_find_by_uuid (newbrickinfo->uuid, &peerinfo); - if (ret) - goto out; - if ((!peerinfo->connected) || - (peerinfo->state.state != GD_FRIEND_STATE_BEFRIENDED)) { - snprintf(op_errstr, len, "Host %s not connected", - newbrickinfo->hostname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", op_errstr); - ret = -1; - goto out; - } -brick_validation: - if (!glusterd_is_brickpath_available (newbrickinfo->uuid, - newbrickinfo->path)) { - snprintf(op_errstr, len, "Brick: %s not available. Brick may " - "be containing or be contained by an existing brick", - brick); - gf_log (THIS->name, GF_LOG_ERROR, "%s", op_errstr); - ret = -1; - goto out; + if (!uuid_compare (MY_UUID, newbrickinfo->uuid)) { + /* brick is local */ + if (!glusterd_is_brickpath_available (newbrickinfo->uuid, + newbrickinfo->path)) { + snprintf(op_errstr, len, "Brick: %s not available." + " Brick may be containing or be contained " + "by an existing brick", brick); + gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); + ret = -1; + goto out; + } + } else { - ret = 0; + ret = glusterd_friend_find_by_uuid (newbrickinfo->uuid, + &peerinfo); + if (ret) + goto out; + + if ((!peerinfo->connected)) { + snprintf(op_errstr, len, "Host %s not connected", + newbrickinfo->hostname); + gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); + ret = -1; + goto out; + } + + if (peerinfo->state.state != GD_FRIEND_STATE_BEFRIENDED) { + snprintf(op_errstr, len, "Host %s is not in \'Peer " + "in Cluster\' state", + newbrickinfo->hostname); + gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr); + ret = -1; + goto out; + } } + + ret = 0; out: - if (is_allocated && newbrickinfo) + if (is_allocated) glusterd_brickinfo_delete (newbrickinfo); - gf_log (THIS->name, GF_LOG_DEBUG, "returning %d ", ret); + gf_log (this->name, GF_LOG_DEBUG, "returning %d ", ret); return ret; } -- cgit