diff options
author | Krishnan Parthasarathi <kp@gluster.com> | 2012-04-03 15:37:25 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-04-12 23:07:08 -0700 |
commit | 8a45a0e480f7e8c6ea1195f77ce3810d4817dc37 (patch) | |
tree | 9b50579b53228f6a605b4c74e36fe0fb7a3827e2 /xlators/mgmt/glusterd/src/glusterd-op-sm.c | |
parent | b337b755325f75a6fcf65616eaf4467b70b8b245 (diff) |
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 <kp@gluster.com>
Reviewed-on: http://review.gluster.com/3083
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index a577e161c17..1825065a4b4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -504,6 +504,7 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) char msg[2048] = {0}; char *key = NULL; char *key_fixed = NULL; + glusterd_volinfo_t *volinfo = NULL; ret = dict_get_str (dict, "volname", &volname); @@ -522,6 +523,13 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) ret = -1; goto out; } + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) + goto out; + + ret = glusterd_validate_volume_id (dict, volinfo); + if (ret) + goto out; ret = dict_get_str (dict, "key", &key); if (ret) { @@ -568,6 +576,7 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr) gf_boolean_t exists = _gf_false; glusterd_peerinfo_t *peerinfo = NULL; char msg[2048] = {0,}; + glusterd_volinfo_t *volinfo = NULL; ret = dict_get_str (dict, "hostname", &hostname); if (ret) { @@ -607,6 +616,13 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr) ret = -1; goto out; } + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) + goto out; + + ret = glusterd_validate_volume_id (dict, volinfo); + if (ret) + goto out; } else { ret = 0; } @@ -664,6 +680,10 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) goto out; } + ret = glusterd_validate_volume_id (dict, volinfo); + if (ret) + goto out; + ret = glusterd_is_volume_started (volinfo); if (!ret) { snprintf (msg, sizeof (msg), "Volume %s is not started", @@ -799,6 +819,10 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr) goto out; } + ret = glusterd_validate_volume_id (dict, volinfo); + if (ret) + goto out; + ret = dict_get_int32 (dict, "op", &stats_op); if (ret) { snprintf (msg, sizeof (msg), "Volume profile op get failed"); @@ -1771,6 +1795,9 @@ glusterd_op_build_payload (dict_t **req) void *ctx = NULL; dict_t *req_dict = NULL; glusterd_op_t op = GD_OP_NONE; + char *volname = NULL; + char *volid = NULL; + glusterd_volinfo_t *volinfo = NULL; GF_ASSERT (req); @@ -1820,6 +1847,32 @@ glusterd_op_build_payload (dict_t **req) case GD_OP_DEFRAG_BRICK_VOLUME: { dict_t *dict = ctx; + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_log (THIS->name, GF_LOG_CRITICAL, + "volname is not present in " + "operation ctx"); + goto out; + } + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "volume %s not present in " + "the cluster", volname); + goto out; + } + volid = gf_strdup (uuid_utoa (volinfo->volume_id)); + if (!volid) { + ret = -1; + goto out; + } + ret = dict_set_dynstr (dict, "vol-id", volid); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Failed to set volume id in " + "dictionary"); + goto out; + } dict_copy (dict, req_dict); } break; |