From 28397cae4102ac3f08576ebaf071ad92683097e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Thu, 2 Apr 2015 15:51:30 +0200 Subject: Avoid conflict between contrib/uuid and system uuid glusterfs relies on Linux uuid implementation, which API is incompatible with most other systems's uuid. As a result, libglusterfs has to embed contrib/uuid, which is the Linux implementation, on non Linux systems. This implementation is incompatible with systtem's built in, but the symbols have the same names. Usually this is not a problem because when we link with -lglusterfs, libc's symbols are trumped. However there is a problem when a program not linked with -lglusterfs will dlopen() glusterfs component. In such a case, libc's uuid implementation is already loaded in the calling program, and it will be used instead of libglusterfs's implementation, causing crashes. A possible workaround is to use pre-load libglusterfs in the calling program (using LD_PRELOAD on NetBSD for instance), but such a mechanism is not portable, nor is it flexible. A much better approach is to rename libglusterfs's uuid_* functions to gf_uuid_* to avoid any possible conflict. This is what this change attempts. BUG: 1206587 Change-Id: I9ccd3e13afed1c7fc18508e92c7beb0f5d49f31a Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/10017 Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 58 +++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index a596d3eb30c..f20a12b25d9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -163,7 +163,7 @@ glusterd_find_missed_snap (dict_t *rsp_dict, glusterd_volinfo_t *vol, brick_count = 0; cds_list_for_each_entry (brickinfo, &vol->bricks, brick_list) { - if (!uuid_compare (brickinfo->uuid, MY_UUID)) { + if (!gf_uuid_compare (brickinfo->uuid, MY_UUID)) { /* If the brick belongs to the same node */ brick_count++; continue; @@ -171,7 +171,7 @@ glusterd_find_missed_snap (dict_t *rsp_dict, glusterd_volinfo_t *vol, rcu_read_lock (); cds_list_for_each_entry_rcu (peerinfo, peers, uuid_list) { - if (uuid_compare (peerinfo->uuid, brickinfo->uuid)) { + if (gf_uuid_compare (peerinfo->uuid, brickinfo->uuid)) { /* If the brick doesnt belong to this peer */ continue; } @@ -845,7 +845,7 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict) /* Restore is successful therefore delete the original volume's * volinfo. If the volinfo is already restored then we should * delete the backend LVMs */ - if (!uuid_is_null (parent_volinfo->restored_from_snap)) { + if (!gf_uuid_is_null (parent_volinfo->restored_from_snap)) { ret = glusterd_lvm_snapshot_remove (rsp_dict, parent_volinfo); if (ret) { @@ -995,7 +995,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { brick_count++; - if (uuid_compare (brickinfo->uuid, MY_UUID)) + if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) continue; snprintf (key, sizeof (key), "snap%d.brick%d.path", @@ -1862,7 +1862,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { - if (uuid_compare (brickinfo->uuid, MY_UUID)) { + if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) { brick_order++; continue; } @@ -2387,11 +2387,11 @@ glusterd_find_snap_by_id (uuid_t snap_id) priv = THIS->private; GF_ASSERT (priv); - if (uuid_is_null(snap_id)) + if (gf_uuid_is_null(snap_id)) goto out; cds_list_for_each_entry (snap, &priv->snapshots, snap_list) { - if (!uuid_compare (snap->snap_id, snap_id)) { + if (!gf_uuid_compare (snap->snap_id, snap_id)) { gf_log (THIS->name, GF_LOG_DEBUG, "Found " "snap %s (%s)", snap->snapname, uuid_utoa (snap->snap_id)); @@ -2529,7 +2529,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol) GF_ASSERT (snap_vol); if ((snap_vol->is_snap_volume == _gf_false) && - (uuid_is_null (snap_vol->restored_from_snap))) { + (gf_uuid_is_null (snap_vol->restored_from_snap))) { gf_log (this->name, GF_LOG_DEBUG, "Not a snap volume, or a restored snap volume."); ret = 0; @@ -2539,7 +2539,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol) brick_count = -1; cds_list_for_each_entry (brickinfo, &snap_vol->bricks, brick_list) { brick_count++; - if (uuid_compare (brickinfo->uuid, MY_UUID)) { + if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) { gf_log (this->name, GF_LOG_DEBUG, "%s:%s belongs to a different node", brickinfo->hostname, brickinfo->path); @@ -2715,7 +2715,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, } cds_list_for_each_entry (brickinfo, &snap_vol->bricks, brick_list) { - if (uuid_compare (brickinfo->uuid, MY_UUID)) + if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) continue; ret = glusterd_brick_stop (snap_vol, brickinfo, _gf_false); @@ -3690,7 +3690,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - uuid_generate (*uuid_ptr); + gf_uuid_generate (*uuid_ptr); ret = dict_set_bin (dict, "snap-id", uuid_ptr, sizeof(uuid_t)); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-id"); @@ -3709,7 +3709,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op, } /* generate internal username and password for the snap*/ - uuid_generate (tmp_uuid); + gf_uuid_generate (tmp_uuid); username = gf_strdup (uuid_utoa (tmp_uuid)); snprintf (key, sizeof(key), "volume%d_username", i); ret = dict_set_dynstr (dict, key, username); @@ -3720,7 +3720,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - uuid_generate (tmp_uuid); + gf_uuid_generate (tmp_uuid); password = gf_strdup (uuid_utoa (tmp_uuid)); snprintf (key, sizeof(key), "volume%d_password", i); ret = dict_set_dynstr (dict, key, password); @@ -3739,7 +3739,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op, } snprintf (key, sizeof(key) - 1, "vol%d_volid", i); - uuid_generate (*uuid_ptr); + gf_uuid_generate (*uuid_ptr); ret = dict_set_bin (dict, key, uuid_ptr, sizeof(uuid_t)); if (ret) { gf_log (this->name, GF_LOG_ERROR, @@ -3876,7 +3876,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - uuid_generate (*uuid_ptr); + gf_uuid_generate (*uuid_ptr); ret = dict_set_bin (dict, "clone-id", uuid_ptr, sizeof(uuid_t)); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Unable to set clone-id"); @@ -3892,7 +3892,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - uuid_generate (tmp_uuid); + gf_uuid_generate (tmp_uuid); username = gf_strdup (uuid_utoa (tmp_uuid)); snprintf (key, sizeof(key), "volume1_username"); ret = dict_set_dynstr (dict, key, username); @@ -3903,7 +3903,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - uuid_generate (tmp_uuid); + gf_uuid_generate (tmp_uuid); password = gf_strdup (uuid_utoa (tmp_uuid)); snprintf (key, sizeof(key), "volume1_password"); ret = dict_set_dynstr (dict, key, password); @@ -3922,7 +3922,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op, } snprintf (key, sizeof(key) - 1, "vol1_volid"); - uuid_generate (*uuid_ptr); + gf_uuid_generate (*uuid_ptr); ret = dict_set_bin (dict, key, uuid_ptr, sizeof(uuid_t)); if (ret) { gf_log (this->name, GF_LOG_ERROR, @@ -4088,7 +4088,7 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict) cds_list_for_each_entry (snap, &priv->snapshots, snap_list) { if (!strcmp (snap->snapname, snapname) || - !uuid_compare (snap->snap_id, *snap_id)) { + !gf_uuid_compare (snap->snap_id, *snap_id)) { gf_log (THIS->name, GF_LOG_ERROR, "Found duplicate snap %s (%s)", snap->snapname, uuid_utoa (snap->snap_id)); @@ -4109,7 +4109,7 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict) } strcpy (snap->snapname, snapname); - uuid_copy (snap->snap_id, *snap_id); + gf_uuid_copy (snap->snap_id, *snap_id); snap->time_stamp = (time_t)time_stamp; /* Set the status as GD_SNAP_STATUS_INIT and once the backend snapshot is taken and snap is really ready to use, set the status to @@ -4466,7 +4466,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict, } if ((snap_brickinfo->snap_status != -1) && - (!uuid_compare (original_brickinfo->uuid, MY_UUID)) && + (!gf_uuid_compare (original_brickinfo->uuid, MY_UUID)) && (!glusterd_is_brick_started (original_brickinfo))) { /* In case if the brick goes down after prevalidate. */ gf_log (this->name, GF_LOG_WARNING, "brick %s:%s is not" @@ -4524,7 +4524,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict, strcpy (snap_brickinfo->hostname, original_brickinfo->hostname); strcpy (snap_brickinfo->path, snap_brick_path); strcpy (snap_brickinfo->mount_dir, original_brickinfo->mount_dir); - uuid_copy (snap_brickinfo->uuid, original_brickinfo->uuid); + gf_uuid_copy (snap_brickinfo->uuid, original_brickinfo->uuid); /* AFR changelog names are based on brick_id and hence the snap * volume's bricks must retain the same ID */ cds_list_add_tail (&snap_brickinfo->brick_list, &snap_vol->bricks); @@ -4565,7 +4565,7 @@ glusterd_update_fs_label (glusterd_brickinfo_t *brickinfo) GF_ASSERT (brickinfo); /* Generate a new UUID */ - uuid_generate (uuid); + gf_uuid_generate (uuid); GLUSTERD_GET_UUID_NOHYPHEN (label, uuid); @@ -4753,7 +4753,7 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap, /* uuid is used as lvm snapshot name. This will avoid restrictions on snapshot names provided by user */ - uuid_copy (snap_vol->volume_id, *snap_volid); + gf_uuid_copy (snap_vol->volume_id, *snap_volid); snap_vol->is_snap_volume = _gf_true; snap_vol->snapshot = snap; @@ -5824,9 +5824,9 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict, goto out; } - if ((uuid_compare (brickinfo->uuid, MY_UUID)) || + if ((gf_uuid_compare (brickinfo->uuid, MY_UUID)) || (brickinfo->snap_status == -1)) { - if (!uuid_compare (brickinfo->uuid, MY_UUID)) { + if (!gf_uuid_compare (brickinfo->uuid, MY_UUID)) { brickcount++; snprintf (key, sizeof (key), "snap-vol%d.brick%d.status", @@ -5937,7 +5937,7 @@ glusterd_create_snap_object_for_clone (dict_t *dict, dict_t *rsp_dict) } strcpy (snap->snapname, snapname); - uuid_copy (snap->snap_id, *snap_id); + gf_uuid_copy (snap->snap_id, *snap_id); ret = 0; @@ -8828,10 +8828,10 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict, /* Following entries need to be derived from origin volume. */ strcpy (new_volinfo->volname, orig_vol->volname); - uuid_copy (new_volinfo->volume_id, orig_vol->volume_id); + gf_uuid_copy (new_volinfo->volume_id, orig_vol->volume_id); new_volinfo->snap_count = orig_vol->snap_count; new_volinfo->snap_max_hard_limit = orig_vol->snap_max_hard_limit; - uuid_copy (new_volinfo->restored_from_snap, + gf_uuid_copy (new_volinfo->restored_from_snap, snap_vol->snapshot->snap_id); /* Use the same version as the original version */ -- cgit