summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-06-23 01:51:47 +0000
committerAnand Avati <avati@gluster.com>2011-06-23 21:31:04 -0700
commitf948a24e51e447642c35bff881057f306768a5e0 (patch)
tree6ba2c5ef2889fea65aebd44b23797ca446c47a2b /xlators/storage/posix/src/posix.c
parent89452c4db44966bb80601c73c3b835d002af9fd5 (diff)
bring in strict check on export directory being re-used for different volume
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/storage/posix/src/posix.c')
-rw-r--r--xlators/storage/posix/src/posix.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 524b700f..95926bbf 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -4355,6 +4355,8 @@ init (xlator_t *this)
int ret = 0;
int op_ret = -1;
int32_t janitor_sleep = 0;
+ uuid_t old_uuid;
+ uuid_t dict_uuid;
dir_data = dict_get (this->options, "directory");
@@ -4389,7 +4391,6 @@ init (xlator_t *this)
goto out;
}
-
/* Check for Extended attribute support, if not present, log it */
op_ret = sys_lsetxattr (dir_data->data,
"trusted.glusterfs.test", "working", 8, 0);
@@ -4426,6 +4427,46 @@ init (xlator_t *this)
}
}
+ tmp_data = dict_get (this->options, "volume-id");
+ if (tmp_data) {
+ op_ret = uuid_parse (tmp_data->data, dict_uuid);
+ if (op_ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "wrong volume-id (%s) set in volume file",
+ tmp_data->data);
+ ret = -1;
+ goto out;
+ }
+ op_ret = sys_lgetxattr (dir_data->data,
+ "trusted.glusterfs.volume-id", old_uuid, 16);
+ if (op_ret == 16) {
+ if (uuid_compare (old_uuid, dict_uuid)) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "mismatching volume-id (%s) recieved. "
+ "already is a part of volume %s ",
+ tmp_data->data, uuid_utoa (old_uuid));
+ ret = -1;
+ goto out;
+ }
+ } else if (op_ret == -1) {
+ /* Using the export for first time */
+ op_ret = sys_lsetxattr (dir_data->data,
+ "trusted.glusterfs.volume-id",
+ dict_uuid, 16, 0);
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to set volume id on export");
+ ret = -1;
+ goto out;
+ }
+ } else {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to fetch volume id from export");
+ goto out;
+ }
+ }
+
_private = GF_CALLOC (1, sizeof (*_private),
gf_posix_mt_posix_private);
if (!_private) {