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/features/marker/src/marker-quota-helper.c | 16 ++-- xlators/features/marker/src/marker-quota.c | 90 +++++++++++------------ xlators/features/marker/src/marker-quota.h | 2 +- xlators/features/marker/src/marker.c | 46 ++++++------ 4 files changed, 77 insertions(+), 77 deletions(-) (limited to 'xlators/features/marker') diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c index f13d5f650b9..67801c86403 100644 --- a/xlators/features/marker/src/marker-quota-helper.c +++ b/xlators/features/marker/src/marker-quota-helper.c @@ -37,8 +37,8 @@ mq_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path) if (parent) loc->parent = inode_ref (parent); - if (!uuid_is_null (inode->gfid)) - uuid_copy (loc->gfid, inode->gfid); + if (!gf_uuid_is_null (inode->gfid)) + gf_uuid_copy (loc->gfid, inode->gfid); loc->path = gf_strdup (path); if (!loc->path) { @@ -140,7 +140,7 @@ mq_get_contribution_node (inode_t *inode, quota_inode_ctx_t *ctx) goto out; list_for_each_entry (temp, &ctx->contribution_head, contri_list) { - if (uuid_compare (temp->gfid, inode->gfid) == 0) { + if (gf_uuid_compare (temp->gfid, inode->gfid) == 0) { contri = temp; goto out; } @@ -171,7 +171,7 @@ __mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution = NULL; if (!loc->parent) { - if (!uuid_is_null (loc->pargfid)) + if (!gf_uuid_is_null (loc->pargfid)) loc->parent = inode_find (loc->inode->table, loc->pargfid); @@ -185,7 +185,7 @@ __mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, list_for_each_entry (contribution, &ctx->contribution_head, contri_list) { if (loc->parent && - uuid_compare (contribution->gfid, loc->parent->gfid) == 0) { + gf_uuid_compare (contribution->gfid, loc->parent->gfid) == 0) { goto out; } } @@ -196,7 +196,7 @@ __mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, contribution->contribution = 0; - uuid_copy (contribution->gfid, loc->parent->gfid); + gf_uuid_copy (contribution->gfid, loc->parent->gfid); LOCK_INIT (&contribution->lock); INIT_LIST_HEAD (&contribution->contri_list); @@ -218,7 +218,7 @@ mq_add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, return NULL; if (((loc->path) && (strcmp (loc->path, "/") == 0)) - || (!loc->path && uuid_is_null (loc->pargfid))) + || (!loc->path && gf_uuid_is_null (loc->pargfid))) return NULL; LOCK (&ctx->lock); @@ -242,7 +242,7 @@ mq_dict_set_contribution (xlator_t *this, dict_t *dict, loc_t *loc, GF_VALIDATE_OR_GOTO ("marker", dict, out); GF_VALIDATE_OR_GOTO ("marker", loc, out); - if (gfid && !uuid_is_null(gfid)) { + if (gfid && !gf_uuid_is_null(gfid)) { GET_CONTRI_KEY (key, gfid, ret); } else if (loc->parent) { GET_CONTRI_KEY (key, loc->parent->gfid, ret); diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index 6034b963dfe..2975e564fa6 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -32,7 +32,7 @@ mq_loc_copy (loc_t *dst, loc_t *src) GF_VALIDATE_OR_GOTO ("marker", src, out); if (src->inode == NULL || - ((src->parent == NULL) && (uuid_is_null (src->pargfid)) + ((src->parent == NULL) && (gf_uuid_is_null (src->pargfid)) && !__is_root_gfid (src->inode->gfid))) { gf_log ("marker", GF_LOG_WARNING, "src loc is not valid"); @@ -173,7 +173,7 @@ mq_loc_fill_from_name (xlator_t *this, loc_t *newloc, loc_t *oldloc, } newloc->parent = inode_ref (oldloc->inode); - uuid_copy (newloc->pargfid, oldloc->inode->gfid); + gf_uuid_copy (newloc->pargfid, oldloc->inode->gfid); if (!oldloc->path) { ret = loc_path (oldloc, NULL); @@ -309,8 +309,8 @@ wind: if (ret) goto err; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); STACK_WIND (frame, mq_release_lock_on_dirty_inode, @@ -382,8 +382,8 @@ mq_update_size_xattr (call_frame_t *frame, void *cookie, xlator_t *this, if (ret) goto err; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -447,8 +447,8 @@ mq_get_dirty_inode_size (call_frame_t *frame, xlator_t *this) if (ret) goto err; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -773,8 +773,8 @@ mq_check_if_still_dirty (call_frame_t *frame, local->d_off = 0; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); GF_UUID_ASSERT (local->loc.gfid); STACK_WIND(frame, @@ -823,10 +823,10 @@ mq_get_dirty_xattr (call_frame_t *frame, void *cookie, xlator_t *this, if (ret) goto err; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); - if (uuid_is_null (local->loc.gfid)) { + if (gf_uuid_is_null (local->loc.gfid)) { ret = -1; goto err; } @@ -992,7 +992,7 @@ mq_create_dirty_xattr (call_frame_t *frame, void *cookie, xlator_t *this, goto err; } - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); STACK_WIND (frame, mq_xattr_creation_release_lock, @@ -1057,9 +1057,9 @@ mq_create_xattr (xlator_t *this, call_frame_t *frame) } if ((local->loc.path && strcmp (local->loc.path, "/") != 0) - || (local->loc.inode && !uuid_is_null (local->loc.inode->gfid) && + || (local->loc.inode && !gf_uuid_is_null (local->loc.inode->gfid) && !__is_root_gfid (local->loc.inode->gfid)) - || (!uuid_is_null (local->loc.gfid) + || (!gf_uuid_is_null (local->loc.gfid) && !__is_root_gfid (local->loc.gfid))) { contri = mq_add_new_contribution_node (this, ctx, &local->loc); if (contri == NULL) @@ -1073,7 +1073,7 @@ mq_create_xattr (xlator_t *this, call_frame_t *frame) goto free_value; } - if (uuid_is_null (local->loc.gfid)) { + if (gf_uuid_is_null (local->loc.gfid)) { ret = -1; goto out; } @@ -1134,10 +1134,10 @@ mq_check_n_set_inode_xattr (call_frame_t *frame, void *cookie, //check contribution xattr if not root if ((local->loc.path && strcmp (local->loc.path, "/") != 0) - || (!uuid_is_null (local->loc.gfid) + || (!gf_uuid_is_null (local->loc.gfid) && !__is_root_gfid (local->loc.gfid)) || (local->loc.inode - && !uuid_is_null (local->loc.inode->gfid) + && !gf_uuid_is_null (local->loc.inode->gfid) && !__is_root_gfid (local->loc.inode->gfid))) { GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret); if (ret < 0) @@ -1153,8 +1153,8 @@ out: return 0; create_xattr: - if (uuid_is_null (local->loc.gfid)) { - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) { + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); } mq_create_xattr (this, frame); @@ -1187,10 +1187,10 @@ mq_get_xattr (call_frame_t *frame, void *cookie, xlator_t *this, goto err; } - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); - if (uuid_is_null (local->loc.gfid)) { + if (gf_uuid_is_null (local->loc.gfid)) { ret = -1; goto err; } @@ -1527,7 +1527,7 @@ mq_mark_undirty (call_frame_t *frame, goto err; } - uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid); + gf_uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid); GF_UUID_ASSERT (local->parent_loc.gfid); STACK_WIND (frame, mq_release_parent_lock, @@ -1613,8 +1613,8 @@ mq_update_parent_size (call_frame_t *frame, goto err; } - if (uuid_is_null (local->parent_loc.gfid)) - uuid_copy (local->parent_loc.gfid, + if (gf_uuid_is_null (local->parent_loc.gfid)) + gf_uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid); GF_UUID_ASSERT (local->parent_loc.gfid); @@ -1741,8 +1741,8 @@ unlock: goto err; } - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -1838,8 +1838,8 @@ mq_fetch_child_size_and_contri (call_frame_t *frame, void *cookie, mq_set_ctx_updation_status (local->ctx, _gf_false); - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -1900,7 +1900,7 @@ mq_markdirty (call_frame_t *frame, void *cookie, if (ret == -1) goto err; - uuid_copy (local->parent_loc.gfid, + gf_uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid); GF_UUID_ASSERT (local->parent_loc.gfid); @@ -2780,10 +2780,10 @@ mq_start_quota_txn_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, goto out; } - if (uuid_is_null (child_loc.gfid)) - uuid_copy (child_loc.gfid, child_loc.inode->gfid); + if (gf_uuid_is_null (child_loc.gfid)) + gf_uuid_copy (child_loc.gfid, child_loc.inode->gfid); - if (uuid_is_null (child_loc.gfid)) { + if (gf_uuid_is_null (child_loc.gfid)) { ret = -1; gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", child_loc.path); @@ -2906,10 +2906,10 @@ mq_create_xattrs_task (void *opaque) this = args->this; THIS = this; - if (uuid_is_null (loc->gfid)) - uuid_copy (loc->gfid, loc->inode->gfid); + if (gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (loc->gfid, loc->inode->gfid); - if (uuid_is_null (loc->gfid)) { + if (gf_uuid_is_null (loc->gfid)) { ret = -1; gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", loc->path); @@ -3228,10 +3228,10 @@ mq_update_dirty_inode_v2 (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, goto out; } - if (uuid_is_null (loc->gfid)) - uuid_copy (loc->gfid, loc->inode->gfid); + if (gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (loc->gfid, loc->inode->gfid); - if (uuid_is_null (loc->gfid)) { + if (gf_uuid_is_null (loc->gfid)) { ret = -1; gf_log (this->name, GF_LOG_DEBUG, "UUID is null for %s", loc->path); @@ -3402,7 +3402,7 @@ mq_inspect_directory_xattr_task (void *opaque) if (!loc_is_root(loc)) { contribution = mq_add_new_contribution_node (this, ctx, loc); if (contribution == NULL) { - if (!uuid_is_null (loc->inode->gfid)) + if (!gf_uuid_is_null (loc->inode->gfid)) gf_log (this->name, GF_LOG_DEBUG, "cannot add a new contribution node " "(%s)", uuid_utoa (loc->inode->gfid)); @@ -3720,9 +3720,9 @@ _mq_inode_remove_done (call_frame_t *frame, void *cookie, xlator_t *this, else { loc.parent = inode_ref (other_dentry->parent); loc.name = gf_strdup (other_dentry->name); - uuid_copy (loc.pargfid , other_dentry->parent->gfid); + gf_uuid_copy (loc.pargfid , other_dentry->parent->gfid); loc.inode = inode_ref (inode); - uuid_copy (loc.gfid, inode->gfid); + gf_uuid_copy (loc.gfid, inode->gfid); inode_path (other_dentry->parent, other_dentry->name, (char **)&loc.path); @@ -3839,7 +3839,7 @@ mq_reduce_parent_size_xattr (call_frame_t *frame, void *cookie, xlator_t *this, if (ret < 0) goto err; - uuid_copy (local->parent_loc.gfid, + gf_uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid); GF_UUID_ASSERT (local->parent_loc.gfid); diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h index 4600954c6a2..a81db7fa684 100644 --- a/xlators/features/marker/src/marker-quota.h +++ b/xlators/features/marker/src/marker-quota.h @@ -63,7 +63,7 @@ do { \ if (_gfid != NULL) { \ char _gfid_unparsed[40]; \ - uuid_unparse (_gfid, _gfid_unparsed); \ + gf_uuid_unparse (_gfid, _gfid_unparsed); \ _ret = snprintf (var, CONTRI_KEY_MAX, \ QUOTA_XATTR_PREFIX \ ".%s.%s." CONTRIBUTION, "quota", \ diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index dc56714a94c..b1eb252c5c2 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -66,8 +66,8 @@ marker_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path) if (inode) { loc->inode = inode_ref (inode); - if (uuid_is_null (loc->gfid)) { - uuid_copy (loc->gfid, loc->inode->gfid); + if (gf_uuid_is_null (loc->gfid)) { + gf_uuid_copy (loc->gfid, loc->inode->gfid); } } @@ -501,8 +501,8 @@ marker_start_setxattr (call_frame_t *frame, xlator_t *this) if (!dict) goto out; - if (local->loc.inode && uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (local->loc.inode && gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -605,8 +605,8 @@ marker_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1 || local == NULL) goto out; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); priv = this->private; @@ -679,8 +679,8 @@ marker_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1 || local == NULL) goto out; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); priv = this->private; @@ -1089,7 +1089,7 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this, if (priv->feature_enabled & GF_XTIME) { //update marks on oldpath - uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid); + gf_uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid); marker_xtime_update_marks (this, oplocal); marker_xtime_update_marks (this, local); } @@ -1244,7 +1244,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (newloc.name) newloc.name++; newloc.parent = inode_ref (local->loc.parent); - uuid_copy (newloc.gfid, oplocal->loc.inode->gfid); + gf_uuid_copy (newloc.gfid, oplocal->loc.inode->gfid); STACK_WIND_COOKIE (frame, marker_rename_release_oldp_lock, frame->cookie, FIRST_CHILD(this), @@ -1265,7 +1265,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (priv->feature_enabled & GF_XTIME) { //update marks on oldpath - uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid); + gf_uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid); marker_xtime_update_marks (this, oplocal); marker_xtime_update_marks (this, local); } @@ -1385,8 +1385,8 @@ marker_get_newpath_contribution (call_frame_t *frame, void *cookie, * reset them in the callback. */ MARKER_SET_UID_GID (frame, local, frame->root); - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, local->loc.inode->gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, local->loc.inode->gfid); GF_UUID_ASSERT (local->loc.gfid); @@ -1439,8 +1439,8 @@ marker_get_oldpath_contribution (call_frame_t *frame, void *cookie, */ MARKER_SET_UID_GID (frame, local, frame->root); - if (uuid_is_null (oplocal->loc.gfid)) - uuid_copy (oplocal->loc.gfid, + if (gf_uuid_is_null (oplocal->loc.gfid)) + gf_uuid_copy (oplocal->loc.gfid, oplocal->loc.inode->gfid); GF_UUID_ASSERT (oplocal->loc.gfid); @@ -1567,7 +1567,7 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, goto err; if ((newloc->inode != NULL) && (newloc->parent != oldloc->parent) - && (uuid_compare (newloc->parent->gfid, + && (gf_uuid_compare (newloc->parent->gfid, oldloc->parent->gfid) < 0)) { lock_on = &local->parent_loc; local->next_lock_on = &oplocal->parent_loc; @@ -1767,8 +1767,8 @@ marker_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1 || local == NULL) goto out; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); priv = this->private; @@ -1841,8 +1841,8 @@ marker_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1 || local == NULL) goto out; - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); priv = this->private; @@ -2675,8 +2675,8 @@ marker_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * would have not yet linked to the inode table which happens * in protocol/server. */ - if (uuid_is_null (local->loc.gfid)) - uuid_copy (local->loc.gfid, buf->ia_gfid); + if (gf_uuid_is_null (local->loc.gfid)) + gf_uuid_copy (local->loc.gfid, buf->ia_gfid); if (priv->feature_enabled & GF_QUOTA) { @@ -2915,7 +2915,7 @@ init_xtime_priv (xlator_t *this, dict_t *options) if((data = dict_get (options, VOLUME_UUID)) != NULL) { priv->volume_uuid = data->data; - ret = uuid_parse (priv->volume_uuid, priv->volume_uuid_bin); + ret = gf_uuid_parse (priv->volume_uuid, priv->volume_uuid_bin); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "invalid volume uuid %s", priv->volume_uuid); -- cgit