From a2ca310cd334bc4c3387107a0931f695efac5ba9 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Sat, 14 Apr 2012 11:58:28 +0530 Subject: glusterd: Disallow (re)-using bricks that were part of any volume Change-Id: I001a67bed1cc3118174a5ddc2f2011e8e48d8ae8 BUG: 812214 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/3147 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Jeff Darcy Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-utils.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'xlators/mgmt') 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; } -- cgit