summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-07-12 05:20:10 +0000
committerAnand Avati <avati@gluster.com>2011-07-14 01:01:55 -0700
commit5d7657c4b48a73305cf35986323121e7dfe92bef (patch)
tree01c188c6922e7e9ad96f4d9555259271802927d4 /xlators/mgmt/glusterd/src/glusterd-utils.c
parent7f4f7765597a7f0daa5bca7c3bcb2479d7ed15bc (diff)
storage/posix: make sure we are starting on a genuine backend
also do the check in 'glusterd' to let the user know of the problems (if any) during the volume create/start time itself. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3065 (make sure the export directories are not re-used as part of another volume) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3065
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 4152fcda792..1880ec502bd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2928,7 +2928,8 @@ glusterd_brick_create_path (char *host, char *path, uuid_t uuid, mode_t mode,
int ret = -1;
char msg[2048] = {0};
struct stat st_buf = {0};
- uuid_t old_uuid;
+ uuid_t gfid = {0,};
+ uuid_t old_uuid = {0,};
char old_uuid_buf[64] = {0,};
ret = stat (path, &st_buf);
@@ -2970,6 +2971,34 @@ check_xattr:
sys_lremovexattr (path, "trusted.glusterfs.test");
}
+ /* Now check if the export directory has some other 'gfid',
+ other than that of root '/' */
+ ret = sys_lgetxattr (path, "trusted.gfid", gfid, 16);
+ if (ret == 16) {
+ if (__is_root_gfid (gfid) != 0) {
+ gf_log (THIS->name, GF_LOG_WARNING,
+ "%s: gfid (%s) is not that of glusterfs '/' ",
+ path, uuid_utoa (gfid));
+ snprintf (msg, sizeof (msg),
+ "'%s:%s' gfid (%s) is not that of "
+ "glusterfs '/' ", host, path, uuid_utoa (gfid));
+ ret = -1;
+ goto out;
+ }
+ } else if (ret != -1) {
+ /* Wrong 'gfid' is set, it should be error */
+ ret = -1;
+ snprintf (msg, sizeof (msg), "'%s:%s' has wrong entry"
+ "for 'gfid'.", host, path);
+ goto out;
+ } else if ((ret == -1) && (errno != ENODATA)) {
+ /* Wrong 'gfid' is set, it should be error */
+ snprintf (msg, sizeof (msg), "'%s:%s' has failed to fetch "
+ "'gfid' (%s)", host, path, strerror (errno));
+ goto out;
+ }
+
+ ret = 0;
if (!uuid)
goto out;
@@ -2990,17 +3019,23 @@ check_xattr:
ret = -1;
goto out;
}
- ret = 0;
- } else if (ret == -1) {
- /* 'volume-id' not set, seems to be a fresh directory */
- ret = 0;
- } else {
+ } else if (ret != -1) {
/* Wrong 'volume-id' is set, it should be error */
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));
+ goto out;
+
}
+ /* if 'ret == -1' then 'volume-id' not set, seems to be a fresh
+ directory */
+ ret = 0;
out:
if (msg[0] != '\0')
*op_errstr = gf_strdup (msg);