diff options
| author | Pranith Kumar K <pranithk@gluster.com> | 2010-09-22 04:21:02 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-22 04:14:32 -0700 | 
| commit | d42f248c58b2ca73fb56a3e091c8e967e2435546 (patch) | |
| tree | c7fb8d6a35206faa42e8d008f37a8aa2fc0a42e0 /xlators/mgmt/glusterd/src/glusterd-utils.c | |
| parent | f47b0c55de9941823fbefe4b3a7e37179d6d4329 (diff) | |
mgmt/glusterd: replace-brick validations
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1657 (validations for replace-brick while stage op)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1657
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 358d6ffe46f..e3592891b18 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1716,3 +1716,37 @@ glusterd_volume_count_get (void)          return ret;  } + +int +glusterd_is_exisiting_brick (char *hostname, char *path) +{ +        glusterd_brickinfo_t            *tmpbrkinfo = NULL; +        glusterd_volinfo_t              *volinfo     = NULL; +        glusterd_conf_t                 *priv = NULL; +        xlator_t                        *this = NULL; +        int                             ret = 0; + +        GF_ASSERT (hostname); +        GF_ASSERT (path); + +        this = THIS; +        GF_ASSERT (this); + +        priv = this->private; +        list_for_each_entry (volinfo, &priv->volumes, vol_list) { + +                list_for_each_entry (tmpbrkinfo, &volinfo->bricks, +                                     brick_list) { + +                        if ((!strcmp(hostname, tmpbrkinfo-> hostname) +                            && !strcmp(path, tmpbrkinfo->path))) { +                                gf_log ("glusterd", GF_LOG_ERROR, "Brick %s:%s" +                                        " already in use", hostname, path); +                                ret = 1; +                                goto out; +                        } +                } +        } +out: +        return ret; +}  | 
