diff options
author | Krishnan Parthasarathi <kp@gluster.com> | 2012-04-14 11:58:28 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-05-03 12:59:41 -0700 |
commit | a2ca310cd334bc4c3387107a0931f695efac5ba9 (patch) | |
tree | 00f1388a4900e16991fa1f77153c3abecaa4729e | |
parent | b8cfc761bd7a664a4ed73999e898973c9718ecee (diff) |
glusterd: Disallow (re)-using bricks that were part of any volume
Change-Id: I001a67bed1cc3118174a5ddc2f2011e8e48d8ae8
BUG: 812214
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-on: http://review.gluster.com/3147
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 6e3a1671015..2b89a69d683 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -4354,7 +4354,6 @@ glusterd_brick_create_path (char *host, char *path, uuid_t uuid, mode_t mode, struct stat st_buf = {0}; uuid_t gfid = {0,}; uuid_t old_uuid = {0,}; - char old_uuid_buf[64] = {0,}; ret = stat (path, &st_buf); if ((!ret) && (!S_ISDIR (st_buf.st_mode))) { @@ -4429,30 +4428,18 @@ check_xattr: /* This 'key' is set when the volume is started for the first time */ ret = sys_lgetxattr (path, "trusted.glusterfs.volume-id", old_uuid, 16); - if (ret == 16) { - if (uuid_compare (old_uuid, uuid)) { - uuid_utoa_r (old_uuid, old_uuid_buf); - gf_log (THIS->name, GF_LOG_WARNING, - "%s: mismatching volume-id (%s) received. " - "already is a part of volume %s ", - path, uuid_utoa (uuid), old_uuid_buf); - snprintf (msg, sizeof (msg), "'%s:%s' has been part of " - "a deleted volume with id %s. Please " - "re-create the brick directory.", - host, path, old_uuid_buf); - ret = -1; - goto out; - } - } else if (ret != -1) { - /* Wrong 'volume-id' is set, it should be error */ + if (ret >= 0) { + snprintf (msg, sizeof (msg), "'%s:%s' has been part of " + "a volume with id %s. Please re-create the brick " + "directory.", host, path, uuid_utoa (old_uuid)); + gf_log (THIS->name, GF_LOG_WARNING, "%s", msg); ret = -1; - snprintf (msg, sizeof (msg), "'%s:%s' has wrong entry" - "for 'volume-id'.", host, path); goto out; + } else if ((ret == -1) && (errno != ENODATA)) { - /* Wrong 'volume-id' is set, it should be error */ snprintf (msg, sizeof (msg), "'%s:%s' : failed to fetch " "'volume-id' (%s)", host, path, strerror (errno)); + gf_log (THIS->name, GF_LOG_WARNING, "%s", msg); goto out; } |