diff options
| author | Raghavendra Bhat <raghavendrabhat@gluster.com> | 2011-04-18 14:23:17 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@gluster.com> | 2011-04-21 03:35:45 -0700 | 
| commit | c1b2279adcc3b3a311221f247c6ee563214cf32c (patch) | |
| tree | 1a71ab2081c8a5c71decb9d84d112015662fa0a4 | |
| parent | 14b9fab371eb7a160fbf15ea4b979d0d98a0e5e0 (diff) | |
do not allow create volume or add-brick if given path or any brick is a part of either
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2803 ([glusterfs-3.2.0qa14]: volume create succeeds even though there is a volume with an export directory in the path of current volume)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2803
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 30 | 
1 files changed, 30 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index c80b3ae95..88f9754bd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -696,6 +696,10 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,          glusterd_brickinfo_t    *brickiter = NULL;          uuid_t                  peer_uuid = {0};          int32_t                 ret = -1; +        int32_t                 brick_path_len = 0; +        int32_t                 path_len = 0; +        int32_t                 smaller_path = 0; +        gf_boolean_t            is_path_smaller = _gf_true;          if (uuid) {                  uuid_copy (peer_uuid, uuid); @@ -705,6 +709,7 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,                          goto out;          }          ret = -1; +        path_len = strlen (path);          list_for_each_entry (brickiter, &volinfo->bricks, brick_list) {                  if (uuid_is_null (brickiter->uuid)) { @@ -712,6 +717,10 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,                          if (ret)                                  goto out;                  } +                brick_path_len = strlen (brickiter->path); +                smaller_path = min (brick_path_len, path_len); +                if (smaller_path != path_len) +                        is_path_smaller = _gf_false;                  if ((!uuid_compare (peer_uuid, brickiter->uuid)) &&                          !strcmp (brickiter->path, path)) {                          gf_log ("", GF_LOG_INFO, "Found brick"); @@ -720,6 +729,27 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,                                  *brickinfo = brickiter;                          break;                  } else { +                        if ((!uuid_compare (peer_uuid, brickiter->uuid)) && +                            !strncmp (brickiter->path, path, smaller_path)) { +                                if (is_path_smaller == _gf_true)  { +                                        if (brickiter->path[smaller_path] == '/') { +                                                ret = 0; +                                                gf_log ("", GF_LOG_INFO, +                                                        "given path %s lies" +                                                        " within %s", path, +                                                        brickiter->path); +                                                break; +                                        } +                                } else +                                        if (path[smaller_path] == '/') { +                                                gf_log ("", GF_LOG_INFO, +                                                        "brick %s is a part of" +                                                        " %s", brickiter->path, +                                                        path); +                                                ret = 0; +                                                break; +                                        } +                        }                          ret = -1;                  }          }  | 
