From 8a45a0e480f7e8c6ea1195f77ce3810d4817dc37 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Tue, 3 Apr 2012 15:37:25 +0530 Subject: glusterd: Added volume-id to 'op' dictionary Volume-id passed in op dictionary would help detect possible split brains among peers in a cluster. The idea is to check if the volume's id and the vol-id that was passed are equal. ie, same volume name, but different volume id indicate that glusterd 'metadata' of one of the participating peers is stale or there is a split brain. This is over and above the existing checksum based validation of peer supplied cluster 'metadata' (ie, volume info file). Change-Id: I1049ef249e417e540ccb4243e450f92fcd0f46f9 BUG: 797734 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/3083 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-utils.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 817cbbc32..7198a1307 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -5328,3 +5328,31 @@ glusterd_is_local_brick (xlator_t *this, glusterd_volinfo_t *volinfo, out: return local; } +int +glusterd_validate_volume_id (dict_t *op_dict, glusterd_volinfo_t *volinfo) +{ + int ret = -1; + char *volid_str = NULL; + uuid_t vol_uid = {0, }; + + ret = dict_get_str (op_dict, "vol-id", &volid_str); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to get volume id"); + goto out; + } + ret = uuid_parse (volid_str, vol_uid); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "Failed to parse uuid"); + goto out; + } + + if (uuid_compare (vol_uid, volinfo->volume_id)) { + gf_log (THIS->name, GF_LOG_ERROR, "Volume ids are different. " + "Possibly a split brain among peers."); + ret = -1; + goto out; + } + +out: + return ret; +} -- cgit