From a7b399fd0ef928c2cca4092b00edb21e70c59f62 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Mon, 21 Dec 2015 23:13:43 +0530 Subject: glusterd: import/export brickinfo->uuid Backport of http://review.gluster.org/#/c/13047/ Given a two node cluster with node N1 & N2, if a dummy node N3 is peer probed, the probed node N3 goes for importing volumes from the probing node (N1), but it still doesn't have information about the other node (N2) about its membership (since peer update happens post volume updates) and hence fail to update its brick's uuid. Post that even though N2 updates N3 about its membership the brick's uuid was never generated. Now as a consequence when N3 initiates a detach of N2, it checks whether the node to be detached has any bricks configured by its respective uuid which is NULL in this case and hence it goes ahead and removes the peer which ideally it shouldn't have (refer to glusterd_friend_contains_vol_bricks () for the logic) Fix is to export brick's uuid and import it at the probed node instead of resolving it. Change-Id: I2d88c72175347550a45ab12aff0ae248e56baa87 BUG: 1297305 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/13047 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Gaurav Kumar Garg Reviewed-by: Avra Sengupta Reviewed-on: http://review.gluster.org/13210 --- xlators/mgmt/glusterd/src/glusterd-utils.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (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 98c519751df..d02fbe5f22f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2550,6 +2550,14 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.brick%d.uuid", + prefix, count, i); + ret = dict_set_dynstr_with_alloc (dict, key, + uuid_utoa(brickinfo->uuid)); + if (ret) + goto out; + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d", prefix, count, i); ret = gd_add_brick_snap_details_to_dict (dict, key, brickinfo); @@ -3014,6 +3022,7 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, glusterd_brickinfo_t *new_brickinfo = NULL; char msg[2048] = {0}; xlator_t *this = NULL; + char *brick_uuid_str = NULL; this = THIS; GF_ASSERT (this); @@ -3071,9 +3080,14 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, if (ret) goto out; - //peerinfo might not be added yet - (void) glusterd_resolve_brick (new_brickinfo); - ret = 0; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.brick%d.uuid", + prefix, vol_count, brick_count); + ret = dict_get_str (peer_data, key, &brick_uuid_str); + if (ret) + goto out; + gf_uuid_parse (brick_uuid_str, new_brickinfo->uuid); + *brickinfo = new_brickinfo; out: if (msg[0]) -- cgit