summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c47
-rw-r--r--xlators/storage/posix/src/posix.c44
2 files changed, 81 insertions, 10 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);
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index fd97980072f..ed241db2869 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3713,8 +3713,9 @@ init (xlator_t *this)
int ret = 0;
int op_ret = -1;
int32_t janitor_sleep = 0;
- uuid_t old_uuid;
- uuid_t dict_uuid;
+ uuid_t old_uuid = {0,};
+ uuid_t dict_uuid = {0,};
+ uuid_t gfid = {0,};
dir_data = dict_get (this->options, "directory");
@@ -3806,7 +3807,7 @@ init (xlator_t *this)
ret = -1;
goto out;
}
- } else if (op_ret == -1) {
+ } else if ((op_ret == -1) && (errno == ENODATA)) {
/* Using the export for first time */
op_ret = sys_lsetxattr (dir_data->data,
"trusted.glusterfs.volume-id",
@@ -3817,20 +3818,53 @@ init (xlator_t *this)
ret = -1;
goto out;
}
+ } else if ((op_ret == -1) && (errno != ENODATA)) {
+ /* Wrong 'volume-id' is set, it should be error */
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: failed to fetch volume-id (%s)",
+ dir_data->data, strerror (errno));
+ goto out;
} else {
ret = -1;
gf_log (this->name, GF_LOG_ERROR,
- "failed to fetch volume id from export");
+ "failed to fetch proper volume id from export");
goto out;
}
}
+ /* Now check if the export directory has some other 'gfid',
+ other than that of root '/' */
+ ret = sys_lgetxattr (dir_data->data, "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 '/' ",
+ dir_data->data, uuid_utoa (gfid));
+ ret = -1;
+ goto out;
+ }
+ } else if (ret != -1) {
+ /* Wrong 'gfid' is set, it should be error */
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: wrong value set as gfid",
+ dir_data->data);
+ ret = -1;
+ goto out;
+ } else if ((ret == -1) && (errno != ENODATA)) {
+ /* Wrong 'gfid' is set, it should be error */
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: failed to fetch gfid (%s)",
+ dir_data->data, strerror (errno));
+ goto out;
+ }
+
op_ret = sys_lgetxattr (dir_data->data, "system.posix_acl_access",
NULL, 0);
if ((op_ret < 0) && (errno == ENOTSUP))
gf_log (this->name, GF_LOG_WARNING,
"Posix access control list is not supported.");
+ ret = 0;
_private = GF_CALLOC (1, sizeof (*_private),
gf_posix_mt_posix_private);
if (!_private) {
@@ -4049,5 +4083,7 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_BOOL },
{ .key = {"janitor-sleep-duration"},
.type = GF_OPTION_TYPE_INT },
+ { .key = {"volume-id"},
+ .type = GF_OPTION_TYPE_ANY },
{ .key = {NULL} }
};