diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2015-04-02 15:51:30 +0200 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-04 10:48:35 -0700 |
commit | 28397cae4102ac3f08576ebaf071ad92683097e8 (patch) | |
tree | 4c8be92299a951c8a28e1dc85bf2671f60da6e08 /xlators/storage/posix | |
parent | 0aebfaa349c7c68c2d59531eabae5a03a748e16a (diff) |
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 <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/10017
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators/storage/posix')
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 10 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-handle.h | 4 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 12 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 44 |
4 files changed, 35 insertions, 35 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index 2bf8813f44c..5aedfe3eb95 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -87,7 +87,7 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize, strcat (real_path, "/"); strcat (real_path, path); loc.inode = inode_ref (inode); - uuid_copy (loc.gfid, inode->gfid); + gf_uuid_copy (loc.gfid, inode->gfid); entry->dict = posix_lookup_xattr_fill (THIS, real_path, &loc, xdata, iabuf); @@ -119,7 +119,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, int ret = -1; uuid_t tmp_gfid = {0, }; - if (!path || !parent || !priv_base_path || uuid_is_null (gfid)) { + if (!path || !parent || !priv_base_path || gf_uuid_is_null (gfid)) { goto out; } @@ -135,7 +135,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, inode = itable->root; memset (&iabuf, 0, sizeof (iabuf)); - uuid_copy (iabuf.ia_gfid, inode->gfid); + gf_uuid_copy (iabuf.ia_gfid, inode->gfid); iabuf.ia_type = inode->ia_type; ret = posix_make_ancestral_node (priv_base_path, path, pathsize, @@ -163,7 +163,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, pgfidstr = strtok_r (linkname + SLEN("../../00/00/"), "/", &saveptr); dir_name = strtok_r (NULL, "/", &saveptr); - uuid_parse (pgfidstr, tmp_gfid); + gf_uuid_parse (pgfidstr, tmp_gfid); ret = posix_make_ancestryfromgfid (this, path, pathsize, head, type, tmp_gfid, handle_size, @@ -609,7 +609,7 @@ posix_mv_old_trash_into_new_trash (xlator_t *this, char *old, char *new) if (!posix_does_old_trash_exists (old)) goto out; - uuid_generate (dest_name); + gf_uuid_generate (dest_name); snprintf (dest_old, sizeof (dest_old), "%s/%s", new, uuid_utoa (dest_name)); ret = rename (old, dest_old); diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h index 3af1a70b31a..e0b5b67e20f 100644 --- a/xlators/storage/posix/src/posix-handle.h +++ b/xlators/storage/posix/src/posix-handle.h @@ -181,7 +181,7 @@ #define MAKE_INODE_HANDLE(rpath, this, loc, iatt_p) do { \ - if (uuid_is_null (loc->gfid)) { \ + if (gf_uuid_is_null (loc->gfid)) { \ gf_log (this->name, GF_LOG_ERROR, \ "null gfid for path %s", (loc)->path); \ break; \ @@ -210,7 +210,7 @@ #define MAKE_ENTRY_HANDLE(entp, parp, this, loc, ent_p) do { \ char *__parp; \ \ - if (uuid_is_null (loc->pargfid) || !loc->name) { \ + if (gf_uuid_is_null (loc->pargfid) || !loc->name) { \ gf_log (this->name, GF_LOG_ERROR, \ "null pargfid/name for path %s", loc->path); \ break; \ diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 4a062970f7d..0638f845e9d 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -420,7 +420,7 @@ posix_fill_ino_from_gfid (xlator_t *this, struct iatt *buf) int i = 0; /* consider least significant 8 bytes of value out of gfid */ - if (uuid_is_null (buf->ia_gfid)) { + if (gf_uuid_is_null (buf->ia_gfid)) { buf->ia_ino = -1; goto out; } @@ -519,7 +519,7 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename, if (basename) posix_fill_gfid_path (this, real_path, &stbuf); else - uuid_copy (stbuf.ia_gfid, gfid); + gf_uuid_copy (stbuf.ia_gfid, gfid); posix_fill_ino_from_gfid (this, &stbuf); @@ -574,8 +574,8 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path, iatt_from_stat (&stbuf, &lstatbuf); - if (gfid && !uuid_is_null (gfid)) - uuid_copy (stbuf.ia_gfid, gfid); + if (gfid && !gf_uuid_is_null (gfid)) + gf_uuid_copy (stbuf.ia_gfid, gfid); else posix_fill_gfid_path (this, path, &stbuf); @@ -724,7 +724,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req) strerror (errno)); goto out; } - uuid_copy (uuid_curr, uuid_req); + gf_uuid_copy (uuid_curr, uuid_req); verify_handle: if (!S_ISDIR (stat.st_mode)) @@ -1125,7 +1125,7 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid) gf_log (this->name, GF_LOG_DEBUG, "%s: %s", newpath, strerror (ENOENT)); stale = _gf_true; - } else if (size == 16 && uuid_compare (gfid, gfid_curr)) { + } else if (size == 16 && gf_uuid_compare (gfid, gfid_curr)) { gf_log (this->name, GF_LOG_DEBUG, "%s: mismatching gfid: %s, " "at %s", hpath, uuid_utoa (gfid_curr), newpath); stale = _gf_true; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 3cc942d50a6..9f20aeb6abc 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -128,13 +128,13 @@ posix_lookup (call_frame_t *frame, xlator_t *this, op_ret = dict_get_int32 (xdata, GF_GFIDLESS_LOOKUP, &gfidless); op_ret = -1; - if (uuid_is_null (loc->pargfid) || (loc->name == NULL)) { + if (gf_uuid_is_null (loc->pargfid) || (loc->name == NULL)) { /* nameless lookup */ MAKE_INODE_HANDLE (real_path, this, loc, &buf); } else { MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &buf); - if (uuid_is_null (loc->inode->gfid)) { + if (gf_uuid_is_null (loc->inode->gfid)) { posix_gfid_heal (this, real_path, loc, xdata); MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &buf); @@ -161,7 +161,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this, } if (priv->update_pgfid_nlinks) { - if (!uuid_is_null (loc->pargfid) && !IA_ISDIR (buf.ia_type)) { + if (!gf_uuid_is_null (loc->pargfid) && !IA_ISDIR (buf.ia_type)) { MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, PGFID_XATTR_KEY_PREFIX, loc->pargfid); @@ -199,7 +199,7 @@ parent: op_ret = entry_ret; out: - if (!op_ret && !gfidless && uuid_is_null (buf.ia_gfid)) { + if (!op_ret && !gfidless && gf_uuid_is_null (buf.ia_gfid)) { gf_log (this->name, GF_LOG_ERROR, "buf->ia_gfid is null for " "%s", (real_path) ? real_path: ""); op_ret = -1; @@ -1314,7 +1314,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, SET_FS_ID (frame->root->uid, gid); op_ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); - if (uuid_req && !uuid_is_null (uuid_req)) { + if (uuid_req && !gf_uuid_is_null (uuid_req)) { op_ret = posix_istat (this, uuid_req, NULL, &stbuf); if ((op_ret == 0) && IA_ISDIR (stbuf.ia_type)) { size = posix_handle_path (this, uuid_req, NULL, NULL, @@ -2004,7 +2004,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, if ((op_ret == -1) && (errno == ENOENT)){ was_present = 0; } else { - uuid_copy (victim, stbuf.ia_gfid); + gf_uuid_copy (victim, stbuf.ia_gfid); if (IA_ISDIR (stbuf.ia_type)) was_dir = 1; nlink = stbuf.ia_nlink; @@ -2020,7 +2020,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, } if (was_present && IA_ISDIR(stbuf.ia_type) && - uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) { + gf_uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) { gf_log (this->name, GF_LOG_WARNING, "found directory %s at %s while renaming %s", uuid_utoa_r (newloc->inode->gfid, olddirid), @@ -2789,7 +2789,7 @@ _fill_writev_xdata (fd_t *fd, dict_t *xdata, xlator_t *this, int is_append) if (fd) inode = fd->inode; - if (!fd || !fd->inode || uuid_is_null (fd->inode->gfid)) { + if (!fd || !fd->inode || gf_uuid_is_null (fd->inode->gfid)) { gf_log_callingfn (this->name, GF_LOG_ERROR, "Invalid Args: " "fd: %p inode: %p gfid:%s", fd, inode?inode:0, inode?uuid_utoa(inode->gfid):"N/A"); @@ -3418,7 +3418,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, loc_t loc = {0, }; loc.inode = inode_ref (leaf_inode); - uuid_copy (loc.gfid, leaf_inode->gfid); + gf_uuid_copy (loc.gfid, leaf_inode->gfid); strcpy (temppath, dirpath); strcat (temppath, "/"); @@ -3510,7 +3510,7 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, goto out; } - uuid_copy (loc->gfid, leaf_inode->gfid); + gf_uuid_copy (loc->gfid, leaf_inode->gfid); MAKE_INODE_HANDLE (leaf_path, this, loc, NULL); if (!leaf_path) { @@ -3592,7 +3592,7 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, nlink_samepgfid = ntoh32 (nlink_samepgfid); strcpy (pgfidstr, key + strlen(PGFID_XATTR_KEY_PREFIX)); - uuid_parse (pgfidstr, pgfid); + gf_uuid_parse (pgfidstr, pgfid); handle_size = POSIX_GFID_HANDLE_SIZE(priv->base_path_length); @@ -3792,7 +3792,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, (void) snprintf (host_buf, 1024, "<POSIX(%s):%s:%s>", priv->base_path, ((priv->node_uuid_pathinfo - && !uuid_is_null(priv->glusterd_uuid)) + && !gf_uuid_is_null(priv->glusterd_uuid)) ? uuid_utoa (priv->glusterd_uuid) : priv->hostname), rpath); @@ -3816,7 +3816,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (loc->inode && name && (strcmp (name, GF_XATTR_NODE_UUID_KEY) == 0) - && !uuid_is_null (priv->glusterd_uuid)) { + && !gf_uuid_is_null (priv->glusterd_uuid)) { (void) snprintf (host_buf, 1024, "%s", uuid_utoa (priv->glusterd_uuid)); @@ -4785,7 +4785,7 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, _fd = pfd->fd; } - if (loc && !uuid_is_null (loc->gfid)) + if (loc && !gf_uuid_is_null (loc->gfid)) MAKE_INODE_HANDLE (real_path, this, loc, NULL); if (real_path) { @@ -5163,12 +5163,12 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, * when the cluster/dht xlator decides to distribute * exended attribute backing file across storage servers. */ - if ((uuid_compare (fd->inode->gfid, rootgfid) == 0) + if ((gf_uuid_compare (fd->inode->gfid, rootgfid) == 0) && (!strcmp(entry->d_name, ".attribute"))) continue; #endif /* __NetBSD__ */ - if ((uuid_compare (fd->inode->gfid, rootgfid) == 0) + if ((gf_uuid_compare (fd->inode->gfid, rootgfid) == 0) && (!strcmp (GF_HIDDEN_PATH, entry->d_name))) { continue; } @@ -5296,7 +5296,7 @@ posix_readdirp_fill (xlator_t *this, fd_t *fd, gf_dirent_t *entries, dict_t *dic inode = inode_grep (fd->inode->table, fd->inode, entry->d_name); if (inode) - uuid_copy (gfid, inode->gfid); + gf_uuid_copy (gfid, inode->gfid); strcpy (&hpath[len+1], entry->d_name); @@ -5725,7 +5725,7 @@ reconfigure (xlator_t *this, dict_t *options) options, bool, out); if (priv->node_uuid_pathinfo && - (uuid_is_null (priv->glusterd_uuid))) { + (gf_uuid_is_null (priv->glusterd_uuid))) { gf_log (this->name, GF_LOG_INFO, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"); @@ -5837,7 +5837,7 @@ init (xlator_t *this) tmp_data = dict_get (this->options, "volume-id"); if (tmp_data) { - op_ret = uuid_parse (tmp_data->data, dict_uuid); + op_ret = gf_uuid_parse (tmp_data->data, dict_uuid); if (op_ret < 0) { gf_log (this->name, GF_LOG_ERROR, "wrong volume-id (%s) set in volume file", @@ -5848,7 +5848,7 @@ init (xlator_t *this) size = sys_lgetxattr (dir_data->data, "trusted.glusterfs.volume-id", old_uuid, 16); if (size == 16) { - if (uuid_compare (old_uuid, dict_uuid)) { + if (gf_uuid_compare (old_uuid, dict_uuid)) { gf_log (this->name, GF_LOG_ERROR, "mismatching volume-id (%s) received. " "already is a part of volume %s ", @@ -6054,7 +6054,7 @@ init (xlator_t *this) ret = dict_get_str (this->options, "glusterd-uuid", &guuid); if (!ret) { - if (uuid_parse (guuid, _private->glusterd_uuid)) + if (gf_uuid_parse (guuid, _private->glusterd_uuid)) gf_log (this->name, GF_LOG_WARNING, "Cannot parse " "glusterd (node) UUID, node-uuid xattr " "request would return - \"No such attribute\""); @@ -6155,7 +6155,7 @@ init (xlator_t *this) GF_OPTION_INIT ("node-uuid-pathinfo", _private->node_uuid_pathinfo, bool, out); if (_private->node_uuid_pathinfo && - (uuid_is_null (_private->glusterd_uuid))) { + (gf_uuid_is_null (_private->glusterd_uuid))) { gf_log (this->name, GF_LOG_INFO, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"); |