summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-06-07 00:45:48 -0700
committerAnand Avati <avati@redhat.com>2012-06-07 17:35:34 -0700
commited648c3b393ec06d0da7c1a9af42286fb3cc978e (patch)
treee4298f43561af76e0d26ce4af2c596bb93c13f8f /xlators/mgmt
parent7efa697c26b31c52f0f8cc976a505ff34bfbe33d (diff)
glusterd: generate node UUID lazily
A commonly faced problem among glusterfs users is: after a fresh installation of glusterfs in a virtual machine, the VM image is cloned to make multiple instances of the server. This breaks glusterd because right after glusterfs installation on the first boot glusterd would have created the node UUID and this gets inherited into the clone. The result is wierd behavior at the time of peer probe where glusterd does not (yet) deal with UUID collisions in a user friendly way. This patch is for the 'prevention' of the issue. The approach here is to avoid generating a UUID on the first start of glusterd, but instead generate a node UUID only when a node UUID is found to be necessary. This naturally avoids the creation of node UUID on first boot and prevents the issue to a large extent. This issue also needs a 'cure' patch, which gives more meaningful error messages to the user and provides CLI to recover from the situations (gluster peer reset?) Change-Id: Ieaaeeaf76ed35385844e98a8e23fc3dd8df5a208 BUG: 811493 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.com/3533 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-log-ops.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h14
13 files changed, 70 insertions, 62 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index f5181f3673a..a0e24b434cd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1012,7 +1012,7 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick,
glusterd_volinfo_reset_defrag_stats (volinfo);
- if (!uuid_compare (brickinfo->uuid, priv->uuid)) {
+ if (!uuid_compare (brickinfo->uuid, MY_UUID)) {
/* Only if the brick is in this glusterd, do the rebalance */
if (need_migrate)
*need_migrate = 1;
@@ -1165,7 +1165,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
goto out;
}
- if (!uuid_compare (brickinfo->uuid, priv->uuid)) {
+ if (!uuid_compare (brickinfo->uuid, MY_UUID)) {
ret = glusterd_brick_create_path (brickinfo->hostname,
brickinfo->path,
volinfo->volume_id,
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 32d4ce7218a..26d1bff152d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -85,7 +85,7 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
dict->extra_stdfree = cli_req.dict.dict_val;
}
- host_uuid = gf_strdup (uuid_utoa(priv->uuid));
+ host_uuid = gf_strdup (uuid_utoa(MY_UUID));
if (host_uuid == NULL) {
gf_log ("glusterd", GF_LOG_ERROR, "failed to get"
"the uuid of the host machine");
@@ -897,7 +897,7 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
/*Check if the gsync is already started in cmd. inited host
* If so initiate add it into the glusterd's priv*/
ret = glusterd_gsync_get_uuid (slave, volinfo, uuid);
- if ((ret == 0) && (uuid_compare (priv->uuid, uuid) == 0)) {
+ if ((ret == 0) && (uuid_compare (MY_UUID, uuid) == 0)) {
ret = glusterd_check_gsync_running_local (volinfo->volname,
slave, &is_running);
if (ret) {
@@ -1418,14 +1418,14 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave,
if (glusterd_gsync_get_uuid (slave, volinfo, uuid))
/* session does not exist, nothing to do */
goto out;
- if (uuid_compare (priv->uuid, uuid) == 0) {
+ if (uuid_compare (MY_UUID, uuid) == 0) {
ret = stop_gsync (volinfo->volname, slave, &status_msg);
if (ret == 0 && status_msg)
ret = dict_set_str (resp_dict, "gsync-status",
status_msg);
if (ret == 0)
ret = glusterd_start_gsync (volinfo, slave,
- uuid_utoa(priv->uuid), NULL);
+ uuid_utoa(MY_UUID), NULL);
}
out:
@@ -1518,7 +1518,7 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo,
priv = THIS->private;
ret = glusterd_gsync_get_uuid (slave, volinfo, uuid);
- if ((ret == 0) && (uuid_compare (priv->uuid, uuid) != 0))
+ if ((ret == 0) && (uuid_compare (MY_UUID, uuid) != 0))
goto out;
if (ret) {
@@ -1781,7 +1781,7 @@ glusterd_do_gsync_log_rotation_mst_slv (glusterd_volinfo_t *volinfo, char *slave
priv = this->private;
ret = glusterd_gsync_get_uuid (slave, volinfo, uuid);
- if ((ret == 0) && (uuid_compare (priv->uuid, uuid) != 0))
+ if ((ret == 0) && (uuid_compare (MY_UUID, uuid) != 0))
goto out;
if (ret) {
@@ -2010,7 +2010,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret)
goto out;
- if (uuid_compare (priv->uuid, uuid) != 0) {
+ if (uuid_compare (MY_UUID, uuid) != 0) {
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index cc8e2d0eea1..51b859857b2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -446,7 +446,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx)
priv = this->private;
GF_ASSERT (priv);
- ret = glusterd_lock (priv->uuid);
+ ret = glusterd_lock (MY_UUID);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
@@ -471,7 +471,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx)
out:
if (locked && ret)
- glusterd_unlock (priv->uuid);
+ glusterd_unlock (MY_UUID);
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -749,7 +749,7 @@ glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
goto out;
}
- if (!uuid_compare (uuid, priv->uuid)) {
+ if (!uuid_compare (uuid, MY_UUID)) {
op_errno = GF_DEPROBE_LOCALHOST;
ret = -1;
goto out;
@@ -1678,7 +1678,7 @@ glusterd_handle_friend_update (rpcsvc_request_t *req)
continue;
}
- if (!uuid_compare (uuid, priv->uuid)) {
+ if (!uuid_compare (uuid, MY_UUID)) {
gf_log ("", GF_LOG_INFO, "Received my uuid as Friend");
i++;
continue;
@@ -1703,7 +1703,7 @@ glusterd_handle_friend_update (rpcsvc_request_t *req)
}
out:
- uuid_copy (rsp.uuid, priv->uuid);
+ uuid_copy (rsp.uuid, MY_UUID);
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
(xdrproc_t)xdr_gd1_mgmt_friend_update_rsp);
if (dict) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 93e037f8747..2056c84b53a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -220,7 +220,7 @@ cont:
ret = -1;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (uuid_compare (brickinfo->uuid, priv->uuid))
+ if (uuid_compare (brickinfo->uuid, MY_UUID))
continue;
if (brick &&
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 7287b84ed9d..d0e8882fb7a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1532,7 +1532,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
if (ret)
goto out;
- if (uuid_compare (brickinfo->uuid, priv->uuid))
+ if (uuid_compare (brickinfo->uuid, MY_UUID))
goto out;
glusterd_add_brick_to_dict (volinfo, brickinfo, rsp_dict,
@@ -1546,7 +1546,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
} else {
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
brick_index++;
- if (uuid_compare (brickinfo->uuid, priv->uuid))
+ if (uuid_compare (brickinfo->uuid, MY_UUID))
continue;
glusterd_add_brick_to_dict (volinfo, brickinfo,
@@ -1684,7 +1684,7 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx)
priv = this->private;
GF_ASSERT (priv);
- /*ret = glusterd_unlock (priv->uuid);
+ /*ret = glusterd_unlock (MY_UUID);
if (ret)
goto out;
@@ -2670,7 +2670,7 @@ glusterd_op_txn_complete ()
glusterd_op_reset_ctx ();
glusterd_op_clear_errstr ();
- ret = glusterd_unlock (priv->uuid);
+ ret = glusterd_unlock (MY_UUID);
/* unlock cant/shouldnt fail here!! */
if (ret) {
@@ -3146,7 +3146,7 @@ glusterd_profile_volume_brick_rsp (void *pending_entry,
snprintf (brick, sizeof (brick), "%s:%s", brickinfo->hostname,
brickinfo->path);
} else if (type == GD_NODE_NFS) {
- snprintf (brick, sizeof (brick), "%s", uuid_utoa (priv->uuid));
+ snprintf (brick, sizeof (brick), "%s", uuid_utoa (MY_UUID));
}
full_brick = gf_strdup (brick);
GF_ASSERT (full_brick);
@@ -3350,7 +3350,7 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict,
if (ret)
gf_log (THIS->name, GF_LOG_ERROR, "Failed to set count");
- snprintf (buf, 1024, "%s", uuid_utoa (priv->uuid));
+ snprintf (buf, 1024, "%s", uuid_utoa (MY_UUID));
node_str = gf_strdup (buf);
snprintf (key, 256, "node-uuid-%d",i);
@@ -3769,7 +3769,7 @@ _select_rxlators_with_local_bricks (xlator_t *this, glusterd_volinfo_t *volinfo,
if (uuid_is_null (brickinfo->uuid))
(void)glusterd_resolve_brick (brickinfo);
- if (!uuid_compare (priv->uuid, brickinfo->uuid))
+ if (!uuid_compare (MY_UUID, brickinfo->uuid))
add = _gf_true;
if (index % replica_count == 0) {
if (add) {
@@ -3809,7 +3809,7 @@ _select_rxlators_for_full_self_heal (xlator_t *this,
uuid_copy (candidate, brickinfo->uuid);
if (index % replica_count == 0) {
- if (!uuid_compare (priv->uuid, candidate)) {
+ if (!uuid_compare (MY_UUID, candidate)) {
_add_rxlator_to_dict (dict, volinfo->volname,
(index-1)/replica_count,
rxlator_count);
@@ -4016,7 +4016,7 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr)
if (ret)
goto out;
- if (uuid_compare (brickinfo->uuid, priv->uuid)||
+ if (uuid_compare (brickinfo->uuid, MY_UUID)||
!glusterd_is_brick_started (brickinfo))
goto out;
@@ -4073,7 +4073,7 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr)
} else {
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
brick_index++;
- if (uuid_compare (brickinfo->uuid, priv->uuid) ||
+ if (uuid_compare (brickinfo->uuid, MY_UUID) ||
!glusterd_is_brick_started (brickinfo)) {
continue;
}
@@ -4118,7 +4118,7 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx)
gf_gld_mt_op_allack_ctx_t);
op = glusterd_op_get_op ();
req_ctx->op = op;
- uuid_copy (req_ctx->uuid, priv->uuid);
+ uuid_copy (req_ctx->uuid, MY_UUID);
ret = glusterd_op_build_payload (&req_ctx->dict, &op_errstr);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index e4384c8e9d4..67c9679772b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -296,7 +296,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
runner_add_arg (&runner, "--xlator-option");
runner_argprintf ( &runner, "*dht.rebalance-cmd=%d",cmd);
runner_add_arg (&runner, "--xlator-option");
- runner_argprintf (&runner, "*dht.node-uuid=%s", uuid_utoa(priv->uuid));
+ runner_argprintf (&runner, "*dht.node-uuid=%s", uuid_utoa(MY_UUID));
runner_add_arg (&runner, "--socket-file");
runner_argprintf (&runner, "%s",sockfile);
runner_add_arg (&runner, "--pid-file");
@@ -464,7 +464,7 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req)
glusterd_rebalance_cmd_attempted_log (cmd, volname);
- ret = dict_set_static_bin (dict, "node-uuid", priv->uuid, 16);
+ ret = dict_set_static_bin (dict, "node-uuid", MY_UUID, 16);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 6d89e4c03d9..240f808fe25 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -1460,7 +1460,7 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- uuid_copy (req.uuid, priv->uuid);
+ uuid_copy (req.uuid, MY_UUID);
req.hostname = gf_strdup (hostname);
req.port = port;
@@ -1505,7 +1505,7 @@ glusterd3_1_friend_add (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- uuid_copy (req.uuid, priv->uuid);
+ uuid_copy (req.uuid, MY_UUID);
req.hostname = peerinfo->hostname;
req.port = peerinfo->port;
@@ -1553,7 +1553,7 @@ glusterd3_1_friend_remove (call_frame_t *frame, xlator_t *this,
peerinfo = event->peerinfo;
- uuid_copy (req.uuid, priv->uuid);
+ uuid_copy (req.uuid, MY_UUID);
req.hostname = peerinfo->hostname;
req.port = peerinfo->port;
ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->peer,
@@ -1598,7 +1598,7 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this,
req.friends.friends_val = dict_buf;
req.friends.friends_len = len;
- uuid_copy (req.uuid, priv->uuid);
+ uuid_copy (req.uuid, MY_UUID);
dummy_frame = create_frame (this, this->ctx->pool);
ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame,
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index dec1bd2d205..1fe78a14995 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -554,7 +554,7 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
list_for_each_entry_safe (volinfo,tmp_volinfo,
&priv->volumes, vol_list) {
if (!glusterd_friend_contains_vol_bricks (volinfo,
- priv->uuid)) {
+ MY_UUID)) {
gf_log (THIS->name, GF_LOG_INFO,
"Deleting stale volume %s", volinfo->volname);
ret = glusterd_delete_volume (volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ffbf52abd9f..68d621571e0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1391,7 +1391,7 @@ glusterd_store_uuid ()
goto out;
}
ret = glusterd_store_save_value (handle->fd, GLUSTERD_STORE_UUID_KEY,
- uuid_utoa (priv->uuid));
+ uuid_utoa (MY_UUID));
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL,
@@ -1444,7 +1444,7 @@ glusterd_retrieve_uuid ()
goto out;
}
- uuid_parse (uuid_str, priv->uuid);
+ uuid_parse (uuid_str, MY_UUID);
out:
if (uuid_str)
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index da778f1e230..58b35cbddcb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -340,7 +340,7 @@ glusterd_get_uuid (uuid_t *uuid)
GF_ASSERT (priv);
- uuid_copy (*uuid, priv->uuid);
+ uuid_copy (*uuid, MY_UUID);
return 0;
}
@@ -1243,7 +1243,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
}
#endif
(void) snprintf (glusterd_uuid, 1024, "*-posix.glusterd-uuid=%s",
- uuid_utoa (priv->uuid));
+ uuid_utoa (MY_UUID));
runner_add_args (&runner, SBIN_DIR"/glusterfsd",
"-s", "localhost", "--volfile-id", volfile,
"-p", pidfile, "-S", socketpath,
@@ -2882,7 +2882,7 @@ glusterd_nodesvc_start (char *server)
server);
snprintf (volfileid, sizeof (volfileid), "gluster/%s", server);
- glusterd_nodesvc_set_socket_filepath (rundir, priv->uuid,
+ glusterd_nodesvc_set_socket_filepath (rundir, MY_UUID,
sockfpath, sizeof (sockfpath));
runinit (&runner);
@@ -2909,7 +2909,7 @@ glusterd_nodesvc_start (char *server)
if (!strcmp (server, "glustershd")) {
snprintf (glusterd_uuid_option, sizeof (glusterd_uuid_option),
- "*replicate*.node-uuid=%s", uuid_utoa (priv->uuid));
+ "*replicate*.node-uuid=%s", uuid_utoa (MY_UUID));
runner_add_args (&runner, "--xlator-option",
glusterd_uuid_option, NULL);
}
@@ -2958,7 +2958,7 @@ glusterd_nodesvc_unlink_socket_file (char *server)
glusterd_get_nodesvc_rundir (server, priv->workdir,
rundir, sizeof (rundir));
- glusterd_nodesvc_set_socket_filepath (rundir, priv->uuid,
+ glusterd_nodesvc_set_socket_filepath (rundir, MY_UUID,
sockfpath, sizeof (sockfpath));
ret = unlink (sockfpath);
@@ -3084,7 +3084,7 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count,
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.path", count);
- ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (priv->uuid)));
+ ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (MY_UUID)));
if (ret)
goto out;
@@ -4186,7 +4186,7 @@ glusterd_hostname_to_uuid (char *hostname, uuid_t uuid)
if (ret)
goto out;
else
- uuid_copy (uuid, priv->uuid);
+ uuid_copy (uuid, MY_UUID);
} else {
uuid_copy (uuid, peerinfo->uuid);
}
@@ -4301,7 +4301,7 @@ glusterd_new_brick_validate (char *brick, glusterd_brickinfo_t *brickinfo,
goto out;
}
- if (!uuid_compare (priv->uuid, newbrickinfo->uuid))
+ if (!uuid_compare (MY_UUID, newbrickinfo->uuid))
goto brick_validation;
ret = glusterd_friend_find_by_uuid (newbrickinfo->uuid, &peerinfo);
if (ret)
@@ -4901,7 +4901,7 @@ glusterd_start_gsync (glusterd_volinfo_t *master_vol, char *slave,
priv = this->private;
GF_ASSERT (priv);
- uuid_utoa_r (priv->uuid, uuid_str);
+ uuid_utoa_r (MY_UUID, uuid_str);
if (strcmp (uuid_str, glusterd_uuid_str))
goto out;
@@ -5437,7 +5437,7 @@ glusterd_uuid_to_hostname (uuid_t uuid)
priv = THIS->private;
GF_ASSERT (priv);
- if (!uuid_compare (priv->uuid, uuid)) {
+ if (!uuid_compare (MY_UUID, uuid)) {
hostname = gf_strdup ("localhost");
}
if (!list_empty (&priv->peers)) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 9ee28733a4f..4bf82a1fe5e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -714,7 +714,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr)
goto out;
}
- if (!uuid_compare (brick_info->uuid, priv->uuid)) {
+ if (!uuid_compare (brick_info->uuid, MY_UUID)) {
ret = glusterd_brick_create_path (brick_info->hostname,
brick_info->path,
volume_uuid,
@@ -1765,7 +1765,7 @@ glusterd_clearlocks_get_local_client_ports (glusterd_volinfo_t *volinfo,
index = -1;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
index++;
- if (uuid_compare (brickinfo->uuid, priv->uuid))
+ if (uuid_compare (brickinfo->uuid, MY_UUID))
continue;
port = pmap_registry_search (THIS, brickinfo->path,
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 5f7298c3436..766c926b802 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -79,23 +79,21 @@ glusterd_opinfo_init ()
return ret;
}
-static int
-glusterd_uuid_init (int flag)
+int
+glusterd_uuid_init ()
{
int ret = -1;
glusterd_conf_t *priv = NULL;
priv = THIS->private;
- if (!flag) {
- ret = glusterd_retrieve_uuid ();
- if (!ret) {
- uuid_copy (glusterd_uuid, priv->uuid);
- gf_log ("glusterd", GF_LOG_INFO,
- "retrieved UUID: %s", uuid_utoa (priv->uuid));
- return 0;
- }
- }
+ ret = glusterd_retrieve_uuid ();
+ if (ret == 0) {
+ uuid_copy (glusterd_uuid, priv->uuid);
+ gf_log ("glusterd", GF_LOG_INFO,
+ "retrieved UUID: %s", uuid_utoa (priv->uuid));
+ return 0;
+ }
uuid_generate (glusterd_uuid);
@@ -978,10 +976,6 @@ init (xlator_t *this)
(void) glusterd_nodesvc_set_running ("glustershd", _gf_false);
/* this->ctx->top = this;*/
- ret = glusterd_uuid_init (first_time);
- if (ret < 0)
- goto out;
-
GLUSTERD_GET_HOOKS_DIR (hooks_dir, GLUSTERD_HOOK_VER, conf);
if (stat (hooks_dir, &buf)) {
ret = glusterd_hooks_create_hooks_directory (dirname);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 1397d9224cb..a774c55c7cb 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -363,6 +363,20 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);
} while (0)
+int glusterd_uuid_init();
+
+#define MY_UUID (__glusterd_uuid())
+
+static inline unsigned char *
+__glusterd_uuid()
+{
+ glusterd_conf_t *priv = THIS->private;
+
+ if (uuid_is_null (priv->uuid))
+ glusterd_uuid_init();
+ return &priv->uuid[0];
+}
+
int32_t
glusterd_brick_from_brickinfo (glusterd_brickinfo_t *brickinfo,
char **new_brick);