diff options
| author | Krishnan Parthasarathi <kparthas@redhat.com> | 2012-11-17 11:59:39 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-23 02:35:10 -0800 | 
| commit | 2fad4eb4efb13d5bf79b4425afa9ce3f87c13e85 (patch) | |
| tree | 850bfdbf0f4a85c81c1dca9b1af1a42a69c405a7 | |
| parent | 4a8f751b7c85b80ed3cbb5c1292200ebfaa49747 (diff) | |
glusterd: brick path availability check only for local bricks
Change-Id: Ica50fb92608f5fd75f8887e0718177faf29d31c4
BUG: 877522
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/4203
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 68 | 
1 files changed, 40 insertions, 28 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 8dc83d5ef0e..28b9cdc78fc 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;  }  | 
